@kya-os/agentshield-nextjs 0.2.11 → 0.2.13

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.
@@ -1,149 +1,136 @@
1
1
  let wasm;
2
2
 
3
- let cachedUint8ArrayMemory0 = null;
4
-
5
- function getUint8ArrayMemory0() {
6
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
8
- }
9
- return cachedUint8ArrayMemory0;
10
- }
3
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
11
4
 
12
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
5
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
13
6
 
14
- cachedTextDecoder.decode();
7
+ let cachedUint8ArrayMemory0 = null;
15
8
 
16
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
- let numBytesDecoded = 0;
18
- function decodeText(ptr, len) {
19
- numBytesDecoded += len;
20
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
- cachedTextDecoder.decode();
23
- numBytesDecoded = len;
24
- }
25
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
26
14
  }
27
15
 
28
16
  function getStringFromWasm0(ptr, len) {
29
- ptr = ptr >>> 0;
30
- return decodeText(ptr, len);
31
- }
32
-
33
- let heap = new Array(128).fill(undefined);
34
-
35
- heap.push(undefined, null, true, false);
36
-
37
- function getObject(idx) {
38
- return heap[idx];
17
+ ptr = ptr >>> 0;
18
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
39
19
  }
40
20
 
41
- let heap_next = heap.length;
42
-
43
- function addHeapObject(obj) {
44
- if (heap_next === heap.length) heap.push(heap.length + 1);
45
- const idx = heap_next;
46
- heap_next = heap[idx];
47
-
48
- heap[idx] = obj;
49
- return idx;
21
+ function logError(f, args) {
22
+ try {
23
+ return f.apply(this, args);
24
+ } catch (e) {
25
+ let error = (function () {
26
+ try {
27
+ return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString();
28
+ } catch(_) {
29
+ return "<failed to stringify thrown value>";
30
+ }
31
+ }());
32
+ console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error);
33
+ throw e;
34
+ }
50
35
  }
51
36
 
52
37
  let WASM_VECTOR_LEN = 0;
53
38
 
54
- const cachedTextEncoder = new TextEncoder();
39
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
55
40
 
56
- if (!('encodeInto' in cachedTextEncoder)) {
57
- cachedTextEncoder.encodeInto = function (arg, view) {
41
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
42
+ ? function (arg, view) {
43
+ return cachedTextEncoder.encodeInto(arg, view);
44
+ }
45
+ : function (arg, view) {
58
46
  const buf = cachedTextEncoder.encode(arg);
59
47
  view.set(buf);
60
48
  return {
61
- read: arg.length,
62
- written: buf.length,
49
+ read: arg.length,
50
+ written: buf.length
63
51
  };
64
- };
65
- }
52
+ });
66
53
 
67
54
  function passStringToWasm0(arg, malloc, realloc) {
68
- if (realloc === undefined) {
69
- const buf = cachedTextEncoder.encode(arg);
70
- const ptr = malloc(buf.length, 1) >>> 0;
71
- getUint8ArrayMemory0()
72
- .subarray(ptr, ptr + buf.length)
73
- .set(buf);
74
- WASM_VECTOR_LEN = buf.length;
75
- return ptr;
76
- }
77
55
 
78
- let len = arg.length;
79
- let ptr = malloc(len, 1) >>> 0;
56
+ if (typeof(arg) !== 'string') throw new Error(`expected a string argument, found ${typeof(arg)}`);
80
57
 
81
- const mem = getUint8ArrayMemory0();
58
+ if (realloc === undefined) {
59
+ const buf = cachedTextEncoder.encode(arg);
60
+ const ptr = malloc(buf.length, 1) >>> 0;
61
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
62
+ WASM_VECTOR_LEN = buf.length;
63
+ return ptr;
64
+ }
65
+
66
+ let len = arg.length;
67
+ let ptr = malloc(len, 1) >>> 0;
82
68
 
83
- let offset = 0;
69
+ const mem = getUint8ArrayMemory0();
84
70
 
85
- for (; offset < len; offset++) {
86
- const code = arg.charCodeAt(offset);
87
- if (code > 0x7f) break;
88
- mem[ptr + offset] = code;
89
- }
71
+ let offset = 0;
90
72
 
91
- if (offset !== len) {
92
- if (offset !== 0) {
93
- arg = arg.slice(offset);
73
+ for (; offset < len; offset++) {
74
+ const code = arg.charCodeAt(offset);
75
+ if (code > 0x7F) break;
76
+ mem[ptr + offset] = code;
94
77
  }
95
- ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0;
96
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
97
- const ret = cachedTextEncoder.encodeInto(arg, view);
98
78
 
99
- offset += ret.written;
100
- ptr = realloc(ptr, len, offset, 1) >>> 0;
101
- }
79
+ if (offset !== len) {
80
+ if (offset !== 0) {
81
+ arg = arg.slice(offset);
82
+ }
83
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
84
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
85
+ const ret = encodeString(arg, view);
86
+ if (ret.read !== arg.length) throw new Error('failed to pass whole string');
87
+ offset += ret.written;
88
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
89
+ }
102
90
 
103
- WASM_VECTOR_LEN = offset;
104
- return ptr;
91
+ WASM_VECTOR_LEN = offset;
92
+ return ptr;
105
93
  }
106
94
 
107
95
  let cachedDataViewMemory0 = null;
108
96
 
109
97
  function getDataViewMemory0() {
110
- if (
111
- cachedDataViewMemory0 === null ||
112
- cachedDataViewMemory0.buffer.detached === true ||
113
- (cachedDataViewMemory0.buffer.detached === undefined &&
114
- cachedDataViewMemory0.buffer !== wasm.memory.buffer)
115
- ) {
116
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
117
- }
118
- return cachedDataViewMemory0;
98
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
99
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
100
+ }
101
+ return cachedDataViewMemory0;
119
102
  }
120
103
 
121
- function dropObject(idx) {
122
- if (idx < 132) return;
123
- heap[idx] = heap_next;
124
- heap_next = idx;
104
+ function _assertNum(n) {
105
+ if (typeof(n) !== 'number') throw new Error(`expected a number argument, found ${typeof(n)}`);
125
106
  }
126
107
 
127
- function takeObject(idx) {
128
- const ret = getObject(idx);
129
- dropObject(idx);
130
- return ret;
108
+ function _assertBoolean(n) {
109
+ if (typeof(n) !== 'boolean') {
110
+ throw new Error(`expected a boolean argument, found ${typeof(n)}`);
111
+ }
131
112
  }
132
113
 
133
114
  function isLikeNone(x) {
134
- return x === undefined || x === null;
115
+ return x === undefined || x === null;
135
116
  }
136
117
  /**
137
118
  * Initialize the AgentShield WASM module
138
119
  */
139
120
  export function init() {
140
- wasm.init();
121
+ wasm.init();
141
122
  }
142
123
 
143
124
  function _assertClass(instance, klass) {
144
- if (!(instance instanceof klass)) {
145
- throw new Error(`expected instance of ${klass.name}`);
146
- }
125
+ if (!(instance instanceof klass)) {
126
+ throw new Error(`expected instance of ${klass.name}`);
127
+ }
128
+ }
129
+
130
+ function takeFromExternrefTable0(idx) {
131
+ const value = wasm.__wbindgen_export_3.get(idx);
132
+ wasm.__externref_table_dealloc(idx);
133
+ return value;
147
134
  }
148
135
  /**
149
136
  * Analyze a request and detect if it's from an agent
@@ -151,20 +138,15 @@ function _assertClass(instance, klass) {
151
138
  * @returns {JsDetectionResult}
152
139
  */
153
140
  export function detect_agent(metadata) {
154
- try {
155
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
156
141
  _assertClass(metadata, JsRequestMetadata);
157
- wasm.detect_agent(retptr, metadata.__wbg_ptr);
158
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
159
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
160
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
161
- if (r2) {
162
- throw takeObject(r1);
142
+ if (metadata.__wbg_ptr === 0) {
143
+ throw new Error('Attempt to use a moved value');
144
+ }
145
+ const ret = wasm.detect_agent(metadata.__wbg_ptr);
146
+ if (ret[2]) {
147
+ throw takeFromExternrefTable0(ret[1]);
163
148
  }
164
- return JsDetectionResult.__wrap(r0);
165
- } finally {
166
- wasm.__wbindgen_add_to_stack_pointer(16);
167
- }
149
+ return JsDetectionResult.__wrap(ret[0]);
168
150
  }
169
151
 
170
152
  /**
@@ -172,1364 +154,479 @@ export function detect_agent(metadata) {
172
154
  * @returns {string}
173
155
  */
174
156
  export function version() {
175
- let deferred1_0;
176
- let deferred1_1;
177
- try {
178
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
179
- wasm.get_version(retptr);
180
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
181
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
182
- deferred1_0 = r0;
183
- deferred1_1 = r1;
184
- return getStringFromWasm0(r0, r1);
185
- } finally {
186
- wasm.__wbindgen_add_to_stack_pointer(16);
187
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
188
- }
189
- }
190
-
191
- /**
192
- * Get the version of the AgentShield library
193
- * @returns {string}
194
- */
195
- export function get_version() {
196
- let deferred1_0;
197
- let deferred1_1;
198
- try {
199
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
200
- wasm.get_version(retptr);
201
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
202
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
203
- deferred1_0 = r0;
204
- deferred1_1 = r1;
205
- return getStringFromWasm0(r0, r1);
206
- } finally {
207
- wasm.__wbindgen_add_to_stack_pointer(16);
208
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
209
- }
210
- }
211
-
212
- /**
213
- * Get build information
214
- * @returns {string}
215
- */
216
- export function get_build_info() {
217
- let deferred1_0;
218
- let deferred1_1;
219
- try {
220
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
221
- wasm.get_build_info(retptr);
222
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
223
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
224
- deferred1_0 = r0;
225
- deferred1_1 = r1;
226
- return getStringFromWasm0(r0, r1);
227
- } finally {
228
- wasm.__wbindgen_add_to_stack_pointer(16);
229
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
230
- }
231
- }
232
-
233
- /**
234
- * Verify an MCP-I proof (VC-JWT token)
235
- *
236
- * This function verifies a Verifiable Credential JWT and extracts the
237
- * principal (issuer) and agent (subject) DIDs.
238
- *
239
- * # Arguments
240
- *
241
- * * `vc_jwt` - The VC-JWT token string (header.payload.signature)
242
- * * `current_time_secs` - Current Unix timestamp in seconds (for expiration check)
243
- *
244
- * # Returns
245
- *
246
- * A `JsMcpIVerificationResult` with verification status and extracted DIDs.
247
- * @param {string} vc_jwt
248
- * @param {bigint} current_time_secs
249
- * @returns {JsMcpIVerificationResult}
250
- */
251
- export function verify_mcp_i_proof(vc_jwt, current_time_secs) {
252
- const ptr0 = passStringToWasm0(vc_jwt, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
253
- const len0 = WASM_VECTOR_LEN;
254
- const ret = wasm.verify_mcp_i_proof(ptr0, len0, current_time_secs);
255
- return JsMcpIVerificationResult.__wrap(ret);
256
- }
257
-
258
- /**
259
- * Resolve a did:key identifier to its public key
260
- *
261
- * # Arguments
262
- *
263
- * * `did` - The did:key identifier (e.g., "did:key:z6Mkf...")
264
- *
265
- * # Returns
266
- *
267
- * A `JsDidKeyResult` with the resolved public key or an error.
268
- * @param {string} did
269
- * @returns {JsDidKeyResult}
270
- */
271
- export function resolve_did_key_wasm(did) {
272
- const ptr0 = passStringToWasm0(did, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
273
- const len0 = WASM_VECTOR_LEN;
274
- const ret = wasm.resolve_did_key_wasm(ptr0, len0);
275
- return JsDidKeyResult.__wrap(ret);
276
- }
277
-
278
- /**
279
- * Check if a requested scope is permitted by granted scopes
280
- *
281
- * # Arguments
282
- *
283
- * * `requested` - The scope being requested (e.g., "read:email")
284
- * * `granted_json` - JSON array of granted scopes (e.g., "[\"read:*\", \"write:calendar\"]")
285
- *
286
- * # Returns
287
- *
288
- * A `JsScopeCheckResult` indicating whether the scope is permitted.
289
- * @param {string} requested
290
- * @param {string} granted_json
291
- * @returns {JsScopeCheckResult}
292
- */
293
- export function check_delegation_scope(requested, granted_json) {
294
- const ptr0 = passStringToWasm0(requested, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
295
- const len0 = WASM_VECTOR_LEN;
296
- const ptr1 = passStringToWasm0(granted_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
297
- const len1 = WASM_VECTOR_LEN;
298
- const ret = wasm.check_delegation_scope(ptr0, len0, ptr1, len1);
299
- return JsScopeCheckResult.__wrap(ret);
300
- }
301
-
302
- /**
303
- * Verify a delegation with time constraints
304
- *
305
- * # Arguments
306
- *
307
- * * `requested` - The scope being requested
308
- * * `granted_json` - JSON array of granted scopes
309
- * * `not_before` - Optional Unix timestamp (0 to skip)
310
- * * `not_after` - Optional Unix timestamp (0 to skip)
311
- * * `current_time` - Current Unix timestamp (0 to skip time checks)
312
- *
313
- * # Returns
314
- *
315
- * A `JsScopeCheckResult` indicating whether the delegation is valid.
316
- * @param {string} requested
317
- * @param {string} granted_json
318
- * @param {bigint} not_before
319
- * @param {bigint} not_after
320
- * @param {bigint} current_time
321
- * @returns {JsScopeCheckResult}
322
- */
323
- export function verify_delegation_scope(
324
- requested,
325
- granted_json,
326
- not_before,
327
- not_after,
328
- current_time
329
- ) {
330
- const ptr0 = passStringToWasm0(requested, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
331
- const len0 = WASM_VECTOR_LEN;
332
- const ptr1 = passStringToWasm0(granted_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
333
- const len1 = WASM_VECTOR_LEN;
334
- const ret = wasm.verify_delegation_scope(
335
- ptr0,
336
- len0,
337
- ptr1,
338
- len1,
339
- not_before,
340
- not_after,
341
- current_time
342
- );
343
- return JsScopeCheckResult.__wrap(ret);
344
- }
345
-
346
- /**
347
- * Evaluate a request against a policy configuration
348
- *
349
- * # Arguments
350
- *
351
- * * `policy_json` - Policy configuration as JSON string
352
- * * `context_json` - Evaluation context as JSON string
353
- *
354
- * # Returns
355
- *
356
- * A `JsPolicyEvaluationResult` with the enforcement action and reason.
357
- *
358
- * # Example
359
- *
360
- * ```javascript
361
- * const policy = JSON.stringify({
362
- * version: "1.0.0",
363
- * enabled: true,
364
- * defaultAction: "allow",
365
- * thresholds: { confidenceThreshold: 80, confidenceAction: "block" },
366
- * denyList: [],
367
- * allowList: [],
368
- * rules: []
369
- * });
370
- *
371
- * const context = JSON.stringify({
372
- * agentType: "ai_agent",
373
- * agentName: "ChatGPT",
374
- * confidence: 95
375
- * });
376
- *
377
- * const result = evaluate_policy(policy, context);
378
- * console.log(result.action); // "block" (confidence exceeded threshold)
379
- * ```
380
- * @param {string} policy_json
381
- * @param {string} context_json
382
- * @returns {JsPolicyEvaluationResult}
383
- */
384
- export function evaluate_policy(policy_json, context_json) {
385
- try {
386
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
387
- const ptr0 = passStringToWasm0(policy_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
388
- const len0 = WASM_VECTOR_LEN;
389
- const ptr1 = passStringToWasm0(context_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
390
- const len1 = WASM_VECTOR_LEN;
391
- wasm.evaluate_policy(retptr, ptr0, len0, ptr1, len1);
392
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
393
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
394
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
395
- if (r2) {
396
- throw takeObject(r1);
397
- }
398
- return JsPolicyEvaluationResult.__wrap(r0);
399
- } finally {
400
- wasm.__wbindgen_add_to_stack_pointer(16);
401
- }
402
- }
403
-
404
- /**
405
- * Check if a policy allows a request (convenience function)
406
- *
407
- * # Arguments
408
- *
409
- * * `policy_json` - Policy configuration as JSON string
410
- * * `context_json` - Evaluation context as JSON string
411
- *
412
- * # Returns
413
- *
414
- * `true` if the request is allowed, `false` otherwise.
415
- * @param {string} policy_json
416
- * @param {string} context_json
417
- * @returns {boolean}
418
- */
419
- export function policy_allows(policy_json, context_json) {
420
- const ptr0 = passStringToWasm0(policy_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
421
- const len0 = WASM_VECTOR_LEN;
422
- const ptr1 = passStringToWasm0(context_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
423
- const len1 = WASM_VECTOR_LEN;
424
- const ret = wasm.policy_allows(ptr0, len0, ptr1, len1);
425
- return ret !== 0;
426
- }
427
-
428
- const JsDetectionResultFinalization =
429
- typeof FinalizationRegistry === 'undefined'
430
- ? { register: () => {}, unregister: () => {} }
431
- : new FinalizationRegistry((ptr) => wasm.__wbg_jsdetectionresult_free(ptr >>> 0, 1));
432
- /**
433
- * JavaScript-compatible detection result
434
- */
435
- export class JsDetectionResult {
436
- static __wrap(ptr) {
437
- ptr = ptr >>> 0;
438
- const obj = Object.create(JsDetectionResult.prototype);
439
- obj.__wbg_ptr = ptr;
440
- JsDetectionResultFinalization.register(obj, obj.__wbg_ptr, obj);
441
- return obj;
442
- }
443
-
444
- __destroy_into_raw() {
445
- const ptr = this.__wbg_ptr;
446
- this.__wbg_ptr = 0;
447
- JsDetectionResultFinalization.unregister(this);
448
- return ptr;
449
- }
450
-
451
- free() {
452
- const ptr = this.__destroy_into_raw();
453
- wasm.__wbg_jsdetectionresult_free(ptr, 0);
454
- }
455
- /**
456
- * Whether the request was identified as coming from an agent
457
- * @returns {boolean}
458
- */
459
- get is_agent() {
460
- const ret = wasm.__wbg_get_jsdetectionresult_is_agent(this.__wbg_ptr);
461
- return ret !== 0;
462
- }
463
- /**
464
- * Whether the request was identified as coming from an agent
465
- * @param {boolean} arg0
466
- */
467
- set is_agent(arg0) {
468
- wasm.__wbg_set_jsdetectionresult_is_agent(this.__wbg_ptr, arg0);
469
- }
470
- /**
471
- * Confidence score (0.0 to 1.0 scale)
472
- * @returns {number}
473
- */
474
- get confidence() {
475
- const ret = wasm.__wbg_get_jsdetectionresult_confidence(this.__wbg_ptr);
476
- return ret;
477
- }
478
- /**
479
- * Confidence score (0.0 to 1.0 scale)
480
- * @param {number} arg0
481
- */
482
- set confidence(arg0) {
483
- wasm.__wbg_set_jsdetectionresult_confidence(this.__wbg_ptr, arg0);
484
- }
485
- /**
486
- * Get the detected agent name
487
- * @returns {string | undefined}
488
- */
489
- get agent() {
490
- try {
491
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
492
- wasm.jsdetectionresult_agent(retptr, this.__wbg_ptr);
493
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
494
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
495
- let v1;
496
- if (r0 !== 0) {
497
- v1 = getStringFromWasm0(r0, r1).slice();
498
- wasm.__wbindgen_export(r0, r1 * 1, 1);
499
- }
500
- return v1;
501
- } finally {
502
- wasm.__wbindgen_add_to_stack_pointer(16);
503
- }
504
- }
505
- /**
506
- * Get the detection class for database storage
507
- * Returns: 'human', 'ai_agent', 'bot', 'automation', or 'unknown'
508
- * @returns {string}
509
- */
510
- get detection_class() {
511
- let deferred1_0;
512
- let deferred1_1;
513
- try {
514
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
515
- wasm.jsdetectionresult_detection_class(retptr, this.__wbg_ptr);
516
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
517
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
518
- deferred1_0 = r0;
519
- deferred1_1 = r1;
520
- return getStringFromWasm0(r0, r1);
521
- } finally {
522
- wasm.__wbindgen_add_to_stack_pointer(16);
523
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
524
- }
525
- }
526
- /**
527
- * Get the verification method as a string
528
- * @returns {string}
529
- */
530
- get verification_method() {
531
157
  let deferred1_0;
532
158
  let deferred1_1;
533
159
  try {
534
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
535
- wasm.jsdetectionresult_verification_method(retptr, this.__wbg_ptr);
536
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
537
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
538
- deferred1_0 = r0;
539
- deferred1_1 = r1;
540
- return getStringFromWasm0(r0, r1);
160
+ const ret = wasm.version();
161
+ deferred1_0 = ret[0];
162
+ deferred1_1 = ret[1];
163
+ return getStringFromWasm0(ret[0], ret[1]);
541
164
  } finally {
542
- wasm.__wbindgen_add_to_stack_pointer(16);
543
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
165
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
544
166
  }
545
- }
546
- /**
547
- * Get the risk level as a string
548
- * @returns {string}
549
- */
550
- get risk_level() {
551
- let deferred1_0;
552
- let deferred1_1;
553
- try {
554
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
555
- wasm.jsdetectionresult_risk_level(retptr, this.__wbg_ptr);
556
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
557
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
558
- deferred1_0 = r0;
559
- deferred1_1 = r1;
560
- return getStringFromWasm0(r0, r1);
561
- } finally {
562
- wasm.__wbindgen_add_to_stack_pointer(16);
563
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
564
- }
565
- }
566
- /**
567
- * Get the timestamp as a string
568
- * @returns {string}
569
- */
570
- get timestamp() {
571
- let deferred1_0;
572
- let deferred1_1;
573
- try {
574
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
575
- wasm.jsdetectionresult_timestamp(retptr, this.__wbg_ptr);
576
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
577
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
578
- deferred1_0 = r0;
579
- deferred1_1 = r1;
580
- return getStringFromWasm0(r0, r1);
581
- } finally {
582
- wasm.__wbindgen_add_to_stack_pointer(16);
583
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
584
- }
585
- }
586
- }
587
- if (Symbol.dispose) JsDetectionResult.prototype[Symbol.dispose] = JsDetectionResult.prototype.free;
588
-
589
- const JsDidKeyResultFinalization =
590
- typeof FinalizationRegistry === 'undefined'
591
- ? { register: () => {}, unregister: () => {} }
592
- : new FinalizationRegistry((ptr) => wasm.__wbg_jsdidkeyresult_free(ptr >>> 0, 1));
593
- /**
594
- * JavaScript-compatible result from did:key resolution
595
- */
596
- export class JsDidKeyResult {
597
- static __wrap(ptr) {
598
- ptr = ptr >>> 0;
599
- const obj = Object.create(JsDidKeyResult.prototype);
600
- obj.__wbg_ptr = ptr;
601
- JsDidKeyResultFinalization.register(obj, obj.__wbg_ptr, obj);
602
- return obj;
603
- }
604
-
605
- __destroy_into_raw() {
606
- const ptr = this.__wbg_ptr;
607
- this.__wbg_ptr = 0;
608
- JsDidKeyResultFinalization.unregister(this);
609
- return ptr;
610
- }
611
-
612
- free() {
613
- const ptr = this.__destroy_into_raw();
614
- wasm.__wbg_jsdidkeyresult_free(ptr, 0);
615
- }
616
- /**
617
- * Whether the resolution was successful
618
- * @returns {boolean}
619
- */
620
- get success() {
621
- const ret = wasm.__wbg_get_jsdidkeyresult_success(this.__wbg_ptr);
622
- return ret !== 0;
623
- }
624
- /**
625
- * Whether the resolution was successful
626
- * @param {boolean} arg0
627
- */
628
- set success(arg0) {
629
- wasm.__wbg_set_jsdidkeyresult_success(this.__wbg_ptr, arg0);
630
- }
631
- /**
632
- * Get the public key as hex string
633
- * @returns {string | undefined}
634
- */
635
- get public_key_hex() {
636
- try {
637
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
638
- wasm.jsdidkeyresult_public_key_hex(retptr, this.__wbg_ptr);
639
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
640
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
641
- let v1;
642
- if (r0 !== 0) {
643
- v1 = getStringFromWasm0(r0, r1).slice();
644
- wasm.__wbindgen_export(r0, r1 * 1, 1);
645
- }
646
- return v1;
647
- } finally {
648
- wasm.__wbindgen_add_to_stack_pointer(16);
649
- }
650
- }
651
- /**
652
- * Get the key type
653
- * @returns {string | undefined}
654
- */
655
- get key_type() {
656
- try {
657
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
658
- wasm.jsdidkeyresult_key_type(retptr, this.__wbg_ptr);
659
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
660
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
661
- let v1;
662
- if (r0 !== 0) {
663
- v1 = getStringFromWasm0(r0, r1).slice();
664
- wasm.__wbindgen_export(r0, r1 * 1, 1);
665
- }
666
- return v1;
667
- } finally {
668
- wasm.__wbindgen_add_to_stack_pointer(16);
669
- }
670
- }
671
- /**
672
- * Get the error message
673
- * @returns {string | undefined}
674
- */
675
- get error() {
676
- try {
677
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
678
- wasm.jsdidkeyresult_error(retptr, this.__wbg_ptr);
679
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
680
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
681
- let v1;
682
- if (r0 !== 0) {
683
- v1 = getStringFromWasm0(r0, r1).slice();
684
- wasm.__wbindgen_export(r0, r1 * 1, 1);
685
- }
686
- return v1;
687
- } finally {
688
- wasm.__wbindgen_add_to_stack_pointer(16);
689
- }
690
- }
691
167
  }
692
- if (Symbol.dispose) JsDidKeyResult.prototype[Symbol.dispose] = JsDidKeyResult.prototype.free;
693
168
 
694
- const JsMcpIVerificationResultFinalization =
695
- typeof FinalizationRegistry === 'undefined'
169
+ const JsDetectionResultFinalization = (typeof FinalizationRegistry === 'undefined')
696
170
  ? { register: () => {}, unregister: () => {} }
697
- : new FinalizationRegistry((ptr) => wasm.__wbg_jsmcpiverificationresult_free(ptr >>> 0, 1));
171
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsdetectionresult_free(ptr >>> 0, 1));
698
172
  /**
699
- * JavaScript-compatible result from MCP-I verification
173
+ * JavaScript-compatible detection result
700
174
  */
701
- export class JsMcpIVerificationResult {
702
- static __wrap(ptr) {
703
- ptr = ptr >>> 0;
704
- const obj = Object.create(JsMcpIVerificationResult.prototype);
705
- obj.__wbg_ptr = ptr;
706
- JsMcpIVerificationResultFinalization.register(obj, obj.__wbg_ptr, obj);
707
- return obj;
708
- }
709
-
710
- __destroy_into_raw() {
711
- const ptr = this.__wbg_ptr;
712
- this.__wbg_ptr = 0;
713
- JsMcpIVerificationResultFinalization.unregister(this);
714
- return ptr;
715
- }
716
-
717
- free() {
718
- const ptr = this.__destroy_into_raw();
719
- wasm.__wbg_jsmcpiverificationresult_free(ptr, 0);
720
- }
721
- /**
722
- * Whether the verification was successful
723
- * @returns {boolean}
724
- */
725
- get verified() {
726
- const ret = wasm.__wbg_get_jsmcpiverificationresult_verified(this.__wbg_ptr);
727
- return ret !== 0;
728
- }
729
- /**
730
- * Whether the verification was successful
731
- * @param {boolean} arg0
732
- */
733
- set verified(arg0) {
734
- wasm.__wbg_set_jsmcpiverificationresult_verified(this.__wbg_ptr, arg0);
735
- }
736
- /**
737
- * Confidence score (0.0 to 1.0 scale) - 0.99 for verified MCP-I
738
- * @returns {number}
739
- */
740
- get confidence() {
741
- const ret = wasm.__wbg_get_jsdetectionresult_confidence(this.__wbg_ptr);
742
- return ret;
743
- }
744
- /**
745
- * Confidence score (0.0 to 1.0 scale) - 0.99 for verified MCP-I
746
- * @param {number} arg0
747
- */
748
- set confidence(arg0) {
749
- wasm.__wbg_set_jsdetectionresult_confidence(this.__wbg_ptr, arg0);
750
- }
751
- /**
752
- * Get the issuer DID (principal)
753
- * @returns {string | undefined}
754
- */
755
- get issuer_did() {
756
- try {
757
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
758
- wasm.jsmcpiverificationresult_issuer_did(retptr, this.__wbg_ptr);
759
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
760
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
761
- let v1;
762
- if (r0 !== 0) {
763
- v1 = getStringFromWasm0(r0, r1).slice();
764
- wasm.__wbindgen_export(r0, r1 * 1, 1);
765
- }
766
- return v1;
767
- } finally {
768
- wasm.__wbindgen_add_to_stack_pointer(16);
769
- }
770
- }
771
- /**
772
- * Get the subject DID (agent)
773
- * @returns {string | undefined}
774
- */
775
- get subject_did() {
776
- try {
777
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
778
- wasm.jsmcpiverificationresult_subject_did(retptr, this.__wbg_ptr);
779
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
780
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
781
- let v1;
782
- if (r0 !== 0) {
783
- v1 = getStringFromWasm0(r0, r1).slice();
784
- wasm.__wbindgen_export(r0, r1 * 1, 1);
785
- }
786
- return v1;
787
- } finally {
788
- wasm.__wbindgen_add_to_stack_pointer(16);
789
- }
790
- }
791
- /**
792
- * Get the error message
793
- * @returns {string | undefined}
794
- */
795
- get error() {
796
- try {
797
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
798
- wasm.jsmcpiverificationresult_error(retptr, this.__wbg_ptr);
799
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
800
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
801
- let v1;
802
- if (r0 !== 0) {
803
- v1 = getStringFromWasm0(r0, r1).slice();
804
- wasm.__wbindgen_export(r0, r1 * 1, 1);
805
- }
806
- return v1;
807
- } finally {
808
- wasm.__wbindgen_add_to_stack_pointer(16);
809
- }
810
- }
811
- }
812
- if (Symbol.dispose)
813
- JsMcpIVerificationResult.prototype[Symbol.dispose] = JsMcpIVerificationResult.prototype.free;
175
+ export class JsDetectionResult {
814
176
 
815
- const JsPolicyEvaluationResultFinalization =
816
- typeof FinalizationRegistry === 'undefined'
817
- ? { register: () => {}, unregister: () => {} }
818
- : new FinalizationRegistry((ptr) => wasm.__wbg_jspolicyevaluationresult_free(ptr >>> 0, 1));
819
- /**
820
- * JavaScript-compatible policy evaluation result
821
- */
822
- export class JsPolicyEvaluationResult {
823
- static __wrap(ptr) {
824
- ptr = ptr >>> 0;
825
- const obj = Object.create(JsPolicyEvaluationResult.prototype);
826
- obj.__wbg_ptr = ptr;
827
- JsPolicyEvaluationResultFinalization.register(obj, obj.__wbg_ptr, obj);
828
- return obj;
829
- }
830
-
831
- __destroy_into_raw() {
832
- const ptr = this.__wbg_ptr;
833
- this.__wbg_ptr = 0;
834
- JsPolicyEvaluationResultFinalization.unregister(this);
835
- return ptr;
836
- }
837
-
838
- free() {
839
- const ptr = this.__destroy_into_raw();
840
- wasm.__wbg_jspolicyevaluationresult_free(ptr, 0);
841
- }
842
- /**
843
- * Get the enforcement action
844
- * @returns {string}
845
- */
846
- get action() {
847
- let deferred1_0;
848
- let deferred1_1;
849
- try {
850
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
851
- wasm.jspolicyevaluationresult_action(retptr, this.__wbg_ptr);
852
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
853
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
854
- deferred1_0 = r0;
855
- deferred1_1 = r1;
856
- return getStringFromWasm0(r0, r1);
857
- } finally {
858
- wasm.__wbindgen_add_to_stack_pointer(16);
859
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
860
- }
861
- }
862
- /**
863
- * Get the reason for the action
864
- * @returns {string}
865
- */
866
- get reason() {
867
- let deferred1_0;
868
- let deferred1_1;
869
- try {
870
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
871
- wasm.jspolicyevaluationresult_reason(retptr, this.__wbg_ptr);
872
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
873
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
874
- deferred1_0 = r0;
875
- deferred1_1 = r1;
876
- return getStringFromWasm0(r0, r1);
877
- } finally {
878
- wasm.__wbindgen_add_to_stack_pointer(16);
879
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
880
- }
881
- }
882
- /**
883
- * Get the matched rule ID
884
- * @returns {string | undefined}
885
- */
886
- get rule_id() {
887
- try {
888
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
889
- wasm.jspolicyevaluationresult_rule_id(retptr, this.__wbg_ptr);
890
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
891
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
892
- let v1;
893
- if (r0 !== 0) {
894
- v1 = getStringFromWasm0(r0, r1).slice();
895
- wasm.__wbindgen_export(r0, r1 * 1, 1);
896
- }
897
- return v1;
898
- } finally {
899
- wasm.__wbindgen_add_to_stack_pointer(16);
900
- }
901
- }
902
- /**
903
- * Get the matched rule name
904
- * @returns {string | undefined}
905
- */
906
- get rule_name() {
907
- try {
908
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
909
- wasm.jspolicyevaluationresult_rule_name(retptr, this.__wbg_ptr);
910
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
911
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
912
- let v1;
913
- if (r0 !== 0) {
914
- v1 = getStringFromWasm0(r0, r1).slice();
915
- wasm.__wbindgen_export(r0, r1 * 1, 1);
916
- }
917
- return v1;
918
- } finally {
919
- wasm.__wbindgen_add_to_stack_pointer(16);
920
- }
921
- }
922
- /**
923
- * Get the redirect URL
924
- * @returns {string | undefined}
925
- */
926
- get redirect_url() {
927
- try {
928
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
929
- wasm.jspolicyevaluationresult_redirect_url(retptr, this.__wbg_ptr);
930
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
931
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
932
- let v1;
933
- if (r0 !== 0) {
934
- v1 = getStringFromWasm0(r0, r1).slice();
935
- wasm.__wbindgen_export(r0, r1 * 1, 1);
936
- }
937
- return v1;
938
- } finally {
939
- wasm.__wbindgen_add_to_stack_pointer(16);
940
- }
941
- }
942
- /**
943
- * Get the custom message
944
- * @returns {string | undefined}
945
- */
946
- get message() {
947
- try {
948
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
949
- wasm.jspolicyevaluationresult_message(retptr, this.__wbg_ptr);
950
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
951
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
952
- let v1;
953
- if (r0 !== 0) {
954
- v1 = getStringFromWasm0(r0, r1).slice();
955
- wasm.__wbindgen_export(r0, r1 * 1, 1);
956
- }
957
- return v1;
958
- } finally {
959
- wasm.__wbindgen_add_to_stack_pointer(16);
177
+ constructor() {
178
+ throw new Error('cannot invoke `new` directly');
179
+ }
180
+
181
+ static __wrap(ptr) {
182
+ ptr = ptr >>> 0;
183
+ const obj = Object.create(JsDetectionResult.prototype);
184
+ obj.__wbg_ptr = ptr;
185
+ JsDetectionResultFinalization.register(obj, obj.__wbg_ptr, obj);
186
+ return obj;
187
+ }
188
+
189
+ __destroy_into_raw() {
190
+ const ptr = this.__wbg_ptr;
191
+ this.__wbg_ptr = 0;
192
+ JsDetectionResultFinalization.unregister(this);
193
+ return ptr;
194
+ }
195
+
196
+ free() {
197
+ const ptr = this.__destroy_into_raw();
198
+ wasm.__wbg_jsdetectionresult_free(ptr, 0);
199
+ }
200
+ /**
201
+ * Whether the request was identified as coming from an agent
202
+ * @returns {boolean}
203
+ */
204
+ get is_agent() {
205
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
206
+ _assertNum(this.__wbg_ptr);
207
+ const ret = wasm.__wbg_get_jsdetectionresult_is_agent(this.__wbg_ptr);
208
+ return ret !== 0;
209
+ }
210
+ /**
211
+ * Whether the request was identified as coming from an agent
212
+ * @param {boolean} arg0
213
+ */
214
+ set is_agent(arg0) {
215
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
216
+ _assertNum(this.__wbg_ptr);
217
+ _assertBoolean(arg0);
218
+ wasm.__wbg_set_jsdetectionresult_is_agent(this.__wbg_ptr, arg0);
219
+ }
220
+ /**
221
+ * Confidence score (0.0 to 1.0)
222
+ * @returns {number}
223
+ */
224
+ get confidence() {
225
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
226
+ _assertNum(this.__wbg_ptr);
227
+ const ret = wasm.__wbg_get_jsdetectionresult_confidence(this.__wbg_ptr);
228
+ return ret;
229
+ }
230
+ /**
231
+ * Confidence score (0.0 to 1.0)
232
+ * @param {number} arg0
233
+ */
234
+ set confidence(arg0) {
235
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
236
+ _assertNum(this.__wbg_ptr);
237
+ wasm.__wbg_set_jsdetectionresult_confidence(this.__wbg_ptr, arg0);
238
+ }
239
+ /**
240
+ * Get the detected agent name
241
+ * @returns {string | undefined}
242
+ */
243
+ get agent() {
244
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
245
+ _assertNum(this.__wbg_ptr);
246
+ const ret = wasm.jsdetectionresult_agent(this.__wbg_ptr);
247
+ let v1;
248
+ if (ret[0] !== 0) {
249
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
250
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
251
+ }
252
+ return v1;
253
+ }
254
+ /**
255
+ * Get the verification method as a string
256
+ * @returns {string}
257
+ */
258
+ get verification_method() {
259
+ let deferred1_0;
260
+ let deferred1_1;
261
+ try {
262
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
263
+ _assertNum(this.__wbg_ptr);
264
+ const ret = wasm.jsdetectionresult_verification_method(this.__wbg_ptr);
265
+ deferred1_0 = ret[0];
266
+ deferred1_1 = ret[1];
267
+ return getStringFromWasm0(ret[0], ret[1]);
268
+ } finally {
269
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
270
+ }
960
271
  }
961
- }
962
- /**
963
- * Get the match type
964
- * @returns {string}
965
- */
966
- get match_type() {
967
- let deferred1_0;
968
- let deferred1_1;
969
- try {
970
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
971
- wasm.jspolicyevaluationresult_match_type(retptr, this.__wbg_ptr);
972
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
973
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
974
- deferred1_0 = r0;
975
- deferred1_1 = r1;
976
- return getStringFromWasm0(r0, r1);
977
- } finally {
978
- wasm.__wbindgen_add_to_stack_pointer(16);
979
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
272
+ /**
273
+ * Get the risk level as a string
274
+ * @returns {string}
275
+ */
276
+ get risk_level() {
277
+ let deferred1_0;
278
+ let deferred1_1;
279
+ try {
280
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
281
+ _assertNum(this.__wbg_ptr);
282
+ const ret = wasm.jsdetectionresult_risk_level(this.__wbg_ptr);
283
+ deferred1_0 = ret[0];
284
+ deferred1_1 = ret[1];
285
+ return getStringFromWasm0(ret[0], ret[1]);
286
+ } finally {
287
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
288
+ }
980
289
  }
981
- }
982
- /**
983
- * Check if the action permits the request to proceed
984
- * Returns true for 'allow' and 'log' (allow but log for monitoring)
985
- * @returns {boolean}
986
- */
987
- is_allowed() {
988
- const ret = wasm.jspolicyevaluationresult_is_allowed(this.__wbg_ptr);
989
- return ret !== 0;
990
- }
991
- /**
992
- * Check if the action blocks the request
993
- * Returns true for 'block', 'redirect', and 'challenge'
994
- * @returns {boolean}
995
- */
996
- is_blocked() {
997
- const ret = wasm.jspolicyevaluationresult_is_blocked(this.__wbg_ptr);
998
- return ret !== 0;
999
- }
1000
- /**
1001
- * Convert to JSON string for serialization
1002
- * @returns {string}
1003
- */
1004
- to_json() {
1005
- let deferred1_0;
1006
- let deferred1_1;
1007
- try {
1008
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1009
- wasm.jspolicyevaluationresult_to_json(retptr, this.__wbg_ptr);
1010
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1011
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1012
- deferred1_0 = r0;
1013
- deferred1_1 = r1;
1014
- return getStringFromWasm0(r0, r1);
1015
- } finally {
1016
- wasm.__wbindgen_add_to_stack_pointer(16);
1017
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
290
+ /**
291
+ * Get the timestamp as a string
292
+ * @returns {string}
293
+ */
294
+ get timestamp() {
295
+ let deferred1_0;
296
+ let deferred1_1;
297
+ try {
298
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
299
+ _assertNum(this.__wbg_ptr);
300
+ const ret = wasm.jsdetectionresult_timestamp(this.__wbg_ptr);
301
+ deferred1_0 = ret[0];
302
+ deferred1_1 = ret[1];
303
+ return getStringFromWasm0(ret[0], ret[1]);
304
+ } finally {
305
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
306
+ }
1018
307
  }
1019
- }
1020
308
  }
1021
- if (Symbol.dispose)
1022
- JsPolicyEvaluationResult.prototype[Symbol.dispose] = JsPolicyEvaluationResult.prototype.free;
1023
309
 
1024
- const JsRequestMetadataFinalization =
1025
- typeof FinalizationRegistry === 'undefined'
310
+ const JsRequestMetadataFinalization = (typeof FinalizationRegistry === 'undefined')
1026
311
  ? { register: () => {}, unregister: () => {} }
1027
- : new FinalizationRegistry((ptr) => wasm.__wbg_jsrequestmetadata_free(ptr >>> 0, 1));
312
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsrequestmetadata_free(ptr >>> 0, 1));
1028
313
  /**
1029
314
  * JavaScript-compatible request metadata
1030
315
  */
1031
316
  export class JsRequestMetadata {
1032
- __destroy_into_raw() {
1033
- const ptr = this.__wbg_ptr;
1034
- this.__wbg_ptr = 0;
1035
- JsRequestMetadataFinalization.unregister(this);
1036
- return ptr;
1037
- }
1038
-
1039
- free() {
1040
- const ptr = this.__destroy_into_raw();
1041
- wasm.__wbg_jsrequestmetadata_free(ptr, 0);
1042
- }
1043
- /**
1044
- * Constructor for JsRequestMetadata
1045
- * @param {string | null | undefined} user_agent
1046
- * @param {string | null | undefined} ip_address
1047
- * @param {string} headers
1048
- * @param {string} timestamp
1049
- * @param {string | null} [url]
1050
- * @param {string | null} [method]
1051
- * @param {string | null} [client_fingerprint]
1052
- * @param {string | null} [tls_fingerprint]
1053
- */
1054
- constructor(
1055
- user_agent,
1056
- ip_address,
1057
- headers,
1058
- timestamp,
1059
- url,
1060
- method,
1061
- client_fingerprint,
1062
- tls_fingerprint
1063
- ) {
1064
- var ptr0 = isLikeNone(user_agent)
1065
- ? 0
1066
- : passStringToWasm0(user_agent, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1067
- var len0 = WASM_VECTOR_LEN;
1068
- var ptr1 = isLikeNone(ip_address)
1069
- ? 0
1070
- : passStringToWasm0(ip_address, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1071
- var len1 = WASM_VECTOR_LEN;
1072
- const ptr2 = passStringToWasm0(headers, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1073
- const len2 = WASM_VECTOR_LEN;
1074
- const ptr3 = passStringToWasm0(timestamp, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1075
- const len3 = WASM_VECTOR_LEN;
1076
- var ptr4 = isLikeNone(url)
1077
- ? 0
1078
- : passStringToWasm0(url, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1079
- var len4 = WASM_VECTOR_LEN;
1080
- var ptr5 = isLikeNone(method)
1081
- ? 0
1082
- : passStringToWasm0(method, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1083
- var len5 = WASM_VECTOR_LEN;
1084
- var ptr6 = isLikeNone(client_fingerprint)
1085
- ? 0
1086
- : passStringToWasm0(client_fingerprint, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1087
- var len6 = WASM_VECTOR_LEN;
1088
- var ptr7 = isLikeNone(tls_fingerprint)
1089
- ? 0
1090
- : passStringToWasm0(tls_fingerprint, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1091
- var len7 = WASM_VECTOR_LEN;
1092
- const ret = wasm.jsrequestmetadata_new(
1093
- ptr0,
1094
- len0,
1095
- ptr1,
1096
- len1,
1097
- ptr2,
1098
- len2,
1099
- ptr3,
1100
- len3,
1101
- ptr4,
1102
- len4,
1103
- ptr5,
1104
- len5,
1105
- ptr6,
1106
- len6,
1107
- ptr7,
1108
- len7
1109
- );
1110
- this.__wbg_ptr = ret >>> 0;
1111
- JsRequestMetadataFinalization.register(this, this.__wbg_ptr, this);
1112
- return this;
1113
- }
1114
- /**
1115
- * Get the user agent
1116
- * @returns {string | undefined}
1117
- */
1118
- get user_agent() {
1119
- try {
1120
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1121
- wasm.jsrequestmetadata_user_agent(retptr, this.__wbg_ptr);
1122
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1123
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1124
- let v1;
1125
- if (r0 !== 0) {
1126
- v1 = getStringFromWasm0(r0, r1).slice();
1127
- wasm.__wbindgen_export(r0, r1 * 1, 1);
1128
- }
1129
- return v1;
1130
- } finally {
1131
- wasm.__wbindgen_add_to_stack_pointer(16);
1132
- }
1133
- }
1134
- /**
1135
- * Get the IP address
1136
- * @returns {string | undefined}
1137
- */
1138
- get ip_address() {
1139
- try {
1140
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1141
- wasm.jsrequestmetadata_ip_address(retptr, this.__wbg_ptr);
1142
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1143
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1144
- let v1;
1145
- if (r0 !== 0) {
1146
- v1 = getStringFromWasm0(r0, r1).slice();
1147
- wasm.__wbindgen_export(r0, r1 * 1, 1);
1148
- }
1149
- return v1;
1150
- } finally {
1151
- wasm.__wbindgen_add_to_stack_pointer(16);
1152
- }
1153
- }
1154
- /**
1155
- * Get the headers as JSON string
1156
- * @returns {string}
1157
- */
1158
- get headers() {
1159
- let deferred1_0;
1160
- let deferred1_1;
1161
- try {
1162
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1163
- wasm.jsrequestmetadata_headers(retptr, this.__wbg_ptr);
1164
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1165
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1166
- deferred1_0 = r0;
1167
- deferred1_1 = r1;
1168
- return getStringFromWasm0(r0, r1);
1169
- } finally {
1170
- wasm.__wbindgen_add_to_stack_pointer(16);
1171
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
1172
- }
1173
- }
1174
- /**
1175
- * Get the timestamp
1176
- * @returns {string}
1177
- */
1178
- get timestamp() {
1179
- let deferred1_0;
1180
- let deferred1_1;
1181
- try {
1182
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1183
- wasm.jsrequestmetadata_timestamp(retptr, this.__wbg_ptr);
1184
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1185
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1186
- deferred1_0 = r0;
1187
- deferred1_1 = r1;
1188
- return getStringFromWasm0(r0, r1);
1189
- } finally {
1190
- wasm.__wbindgen_add_to_stack_pointer(16);
1191
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
1192
- }
1193
- }
1194
- /**
1195
- * Get the URL
1196
- * @returns {string | undefined}
1197
- */
1198
- get url() {
1199
- try {
1200
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1201
- wasm.jsrequestmetadata_url(retptr, this.__wbg_ptr);
1202
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1203
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1204
- let v1;
1205
- if (r0 !== 0) {
1206
- v1 = getStringFromWasm0(r0, r1).slice();
1207
- wasm.__wbindgen_export(r0, r1 * 1, 1);
1208
- }
1209
- return v1;
1210
- } finally {
1211
- wasm.__wbindgen_add_to_stack_pointer(16);
1212
- }
1213
- }
1214
- /**
1215
- * Get the method
1216
- * @returns {string | undefined}
1217
- */
1218
- get method() {
1219
- try {
1220
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1221
- wasm.jsrequestmetadata_method(retptr, this.__wbg_ptr);
1222
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1223
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1224
- let v1;
1225
- if (r0 !== 0) {
1226
- v1 = getStringFromWasm0(r0, r1).slice();
1227
- wasm.__wbindgen_export(r0, r1 * 1, 1);
1228
- }
1229
- return v1;
1230
- } finally {
1231
- wasm.__wbindgen_add_to_stack_pointer(16);
1232
- }
1233
- }
1234
- /**
1235
- * Get the client fingerprint
1236
- * @returns {string | undefined}
1237
- */
1238
- get client_fingerprint() {
1239
- try {
1240
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1241
- wasm.jsrequestmetadata_client_fingerprint(retptr, this.__wbg_ptr);
1242
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1243
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1244
- let v1;
1245
- if (r0 !== 0) {
1246
- v1 = getStringFromWasm0(r0, r1).slice();
1247
- wasm.__wbindgen_export(r0, r1 * 1, 1);
1248
- }
1249
- return v1;
1250
- } finally {
1251
- wasm.__wbindgen_add_to_stack_pointer(16);
1252
- }
1253
- }
1254
- /**
1255
- * Get the TLS fingerprint
1256
- * @returns {string | undefined}
1257
- */
1258
- get tls_fingerprint() {
1259
- try {
1260
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1261
- wasm.jsrequestmetadata_tls_fingerprint(retptr, this.__wbg_ptr);
1262
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1263
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1264
- let v1;
1265
- if (r0 !== 0) {
1266
- v1 = getStringFromWasm0(r0, r1).slice();
1267
- wasm.__wbindgen_export(r0, r1 * 1, 1);
1268
- }
1269
- return v1;
1270
- } finally {
1271
- wasm.__wbindgen_add_to_stack_pointer(16);
1272
- }
1273
- }
1274
- }
1275
- if (Symbol.dispose) JsRequestMetadata.prototype[Symbol.dispose] = JsRequestMetadata.prototype.free;
1276
317
 
1277
- const JsScopeCheckResultFinalization =
1278
- typeof FinalizationRegistry === 'undefined'
1279
- ? { register: () => {}, unregister: () => {} }
1280
- : new FinalizationRegistry((ptr) => wasm.__wbg_jsscopecheckresult_free(ptr >>> 0, 1));
1281
- /**
1282
- * JavaScript-compatible result from scope check
1283
- */
1284
- export class JsScopeCheckResult {
1285
- static __wrap(ptr) {
1286
- ptr = ptr >>> 0;
1287
- const obj = Object.create(JsScopeCheckResult.prototype);
1288
- obj.__wbg_ptr = ptr;
1289
- JsScopeCheckResultFinalization.register(obj, obj.__wbg_ptr, obj);
1290
- return obj;
1291
- }
1292
-
1293
- __destroy_into_raw() {
1294
- const ptr = this.__wbg_ptr;
1295
- this.__wbg_ptr = 0;
1296
- JsScopeCheckResultFinalization.unregister(this);
1297
- return ptr;
1298
- }
1299
-
1300
- free() {
1301
- const ptr = this.__destroy_into_raw();
1302
- wasm.__wbg_jsscopecheckresult_free(ptr, 0);
1303
- }
1304
- /**
1305
- * Whether the scope is permitted
1306
- * @returns {boolean}
1307
- */
1308
- get permitted() {
1309
- const ret = wasm.__wbg_get_jsdidkeyresult_success(this.__wbg_ptr);
1310
- return ret !== 0;
1311
- }
1312
- /**
1313
- * Whether the scope is permitted
1314
- * @param {boolean} arg0
1315
- */
1316
- set permitted(arg0) {
1317
- wasm.__wbg_set_jsdidkeyresult_success(this.__wbg_ptr, arg0);
1318
- }
1319
- /**
1320
- * Get the matching scope
1321
- * @returns {string | undefined}
1322
- */
1323
- get matched_by() {
1324
- try {
1325
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1326
- wasm.jsscopecheckresult_matched_by(retptr, this.__wbg_ptr);
1327
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1328
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1329
- let v1;
1330
- if (r0 !== 0) {
1331
- v1 = getStringFromWasm0(r0, r1).slice();
1332
- wasm.__wbindgen_export(r0, r1 * 1, 1);
1333
- }
1334
- return v1;
1335
- } finally {
1336
- wasm.__wbindgen_add_to_stack_pointer(16);
318
+ __destroy_into_raw() {
319
+ const ptr = this.__wbg_ptr;
320
+ this.__wbg_ptr = 0;
321
+ JsRequestMetadataFinalization.unregister(this);
322
+ return ptr;
323
+ }
324
+
325
+ free() {
326
+ const ptr = this.__destroy_into_raw();
327
+ wasm.__wbg_jsrequestmetadata_free(ptr, 0);
328
+ }
329
+ /**
330
+ * Constructor for JsRequestMetadata
331
+ * @param {string | null | undefined} user_agent
332
+ * @param {string | null | undefined} ip_address
333
+ * @param {string} headers
334
+ * @param {string} timestamp
335
+ * @param {string | null} [url]
336
+ * @param {string | null} [method]
337
+ * @param {string | null} [client_fingerprint]
338
+ */
339
+ constructor(user_agent, ip_address, headers, timestamp, url, method, client_fingerprint) {
340
+ var ptr0 = isLikeNone(user_agent) ? 0 : passStringToWasm0(user_agent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
341
+ var len0 = WASM_VECTOR_LEN;
342
+ var ptr1 = isLikeNone(ip_address) ? 0 : passStringToWasm0(ip_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
343
+ var len1 = WASM_VECTOR_LEN;
344
+ const ptr2 = passStringToWasm0(headers, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
345
+ const len2 = WASM_VECTOR_LEN;
346
+ const ptr3 = passStringToWasm0(timestamp, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
347
+ const len3 = WASM_VECTOR_LEN;
348
+ var ptr4 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
349
+ var len4 = WASM_VECTOR_LEN;
350
+ var ptr5 = isLikeNone(method) ? 0 : passStringToWasm0(method, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
351
+ var len5 = WASM_VECTOR_LEN;
352
+ var ptr6 = isLikeNone(client_fingerprint) ? 0 : passStringToWasm0(client_fingerprint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
353
+ var len6 = WASM_VECTOR_LEN;
354
+ const ret = wasm.jsrequestmetadata_new(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
355
+ this.__wbg_ptr = ret >>> 0;
356
+ JsRequestMetadataFinalization.register(this, this.__wbg_ptr, this);
357
+ return this;
358
+ }
359
+ /**
360
+ * Get the user agent
361
+ * @returns {string | undefined}
362
+ */
363
+ get user_agent() {
364
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
365
+ _assertNum(this.__wbg_ptr);
366
+ const ret = wasm.jsrequestmetadata_user_agent(this.__wbg_ptr);
367
+ let v1;
368
+ if (ret[0] !== 0) {
369
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
370
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
371
+ }
372
+ return v1;
373
+ }
374
+ /**
375
+ * Get the IP address
376
+ * @returns {string | undefined}
377
+ */
378
+ get ip_address() {
379
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
380
+ _assertNum(this.__wbg_ptr);
381
+ const ret = wasm.jsrequestmetadata_ip_address(this.__wbg_ptr);
382
+ let v1;
383
+ if (ret[0] !== 0) {
384
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
385
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
386
+ }
387
+ return v1;
388
+ }
389
+ /**
390
+ * Get the headers as JSON string
391
+ * @returns {string}
392
+ */
393
+ get headers() {
394
+ let deferred1_0;
395
+ let deferred1_1;
396
+ try {
397
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
398
+ _assertNum(this.__wbg_ptr);
399
+ const ret = wasm.jsrequestmetadata_headers(this.__wbg_ptr);
400
+ deferred1_0 = ret[0];
401
+ deferred1_1 = ret[1];
402
+ return getStringFromWasm0(ret[0], ret[1]);
403
+ } finally {
404
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
405
+ }
1337
406
  }
1338
- }
1339
- /**
1340
- * Get the match type
1341
- * @returns {string}
1342
- */
1343
- get match_type() {
1344
- let deferred1_0;
1345
- let deferred1_1;
1346
- try {
1347
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1348
- wasm.jsscopecheckresult_match_type(retptr, this.__wbg_ptr);
1349
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1350
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1351
- deferred1_0 = r0;
1352
- deferred1_1 = r1;
1353
- return getStringFromWasm0(r0, r1);
1354
- } finally {
1355
- wasm.__wbindgen_add_to_stack_pointer(16);
1356
- wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
407
+ /**
408
+ * Get the timestamp
409
+ * @returns {string}
410
+ */
411
+ get timestamp() {
412
+ let deferred1_0;
413
+ let deferred1_1;
414
+ try {
415
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
416
+ _assertNum(this.__wbg_ptr);
417
+ const ret = wasm.jsrequestmetadata_timestamp(this.__wbg_ptr);
418
+ deferred1_0 = ret[0];
419
+ deferred1_1 = ret[1];
420
+ return getStringFromWasm0(ret[0], ret[1]);
421
+ } finally {
422
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
423
+ }
1357
424
  }
1358
- }
1359
- /**
1360
- * Get the error message
1361
- * @returns {string | undefined}
1362
- */
1363
- get error() {
1364
- try {
1365
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1366
- wasm.jsscopecheckresult_error(retptr, this.__wbg_ptr);
1367
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1368
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1369
- let v1;
1370
- if (r0 !== 0) {
1371
- v1 = getStringFromWasm0(r0, r1).slice();
1372
- wasm.__wbindgen_export(r0, r1 * 1, 1);
1373
- }
1374
- return v1;
1375
- } finally {
1376
- wasm.__wbindgen_add_to_stack_pointer(16);
425
+ /**
426
+ * Get the URL
427
+ * @returns {string | undefined}
428
+ */
429
+ get url() {
430
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
431
+ _assertNum(this.__wbg_ptr);
432
+ const ret = wasm.jsrequestmetadata_url(this.__wbg_ptr);
433
+ let v1;
434
+ if (ret[0] !== 0) {
435
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
436
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
437
+ }
438
+ return v1;
439
+ }
440
+ /**
441
+ * Get the method
442
+ * @returns {string | undefined}
443
+ */
444
+ get method() {
445
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
446
+ _assertNum(this.__wbg_ptr);
447
+ const ret = wasm.jsrequestmetadata_method(this.__wbg_ptr);
448
+ let v1;
449
+ if (ret[0] !== 0) {
450
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
451
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
452
+ }
453
+ return v1;
454
+ }
455
+ /**
456
+ * Get the client fingerprint
457
+ * @returns {string | undefined}
458
+ */
459
+ get client_fingerprint() {
460
+ if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
461
+ _assertNum(this.__wbg_ptr);
462
+ const ret = wasm.jsrequestmetadata_client_fingerprint(this.__wbg_ptr);
463
+ let v1;
464
+ if (ret[0] !== 0) {
465
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
466
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
467
+ }
468
+ return v1;
1377
469
  }
1378
- }
1379
470
  }
1380
- if (Symbol.dispose)
1381
- JsScopeCheckResult.prototype[Symbol.dispose] = JsScopeCheckResult.prototype.free;
1382
-
1383
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
1384
471
 
1385
472
  async function __wbg_load(module, imports) {
1386
- if (typeof Response === 'function' && module instanceof Response) {
1387
- if (typeof WebAssembly.instantiateStreaming === 'function') {
1388
- try {
1389
- return await WebAssembly.instantiateStreaming(module, imports);
1390
- } catch (e) {
1391
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
1392
-
1393
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1394
- console.warn(
1395
- '`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n',
1396
- e
1397
- );
1398
- } else {
1399
- throw e;
473
+ if (typeof Response === 'function' && module instanceof Response) {
474
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
475
+ try {
476
+ return await WebAssembly.instantiateStreaming(module, imports);
477
+
478
+ } catch (e) {
479
+ if (module.headers.get('Content-Type') != 'application/wasm') {
480
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
481
+
482
+ } else {
483
+ throw e;
484
+ }
485
+ }
1400
486
  }
1401
- }
1402
- }
1403
487
 
1404
- const bytes = await module.arrayBuffer();
1405
- return await WebAssembly.instantiate(bytes, imports);
1406
- } else {
1407
- const instance = await WebAssembly.instantiate(module, imports);
488
+ const bytes = await module.arrayBuffer();
489
+ return await WebAssembly.instantiate(bytes, imports);
1408
490
 
1409
- if (instance instanceof WebAssembly.Instance) {
1410
- return { instance, module };
1411
491
  } else {
1412
- return instance;
492
+ const instance = await WebAssembly.instantiate(module, imports);
493
+
494
+ if (instance instanceof WebAssembly.Instance) {
495
+ return { instance, module };
496
+
497
+ } else {
498
+ return instance;
499
+ }
1413
500
  }
1414
- }
1415
501
  }
1416
502
 
1417
503
  function __wbg_get_imports() {
1418
- const imports = {};
1419
- imports.wbg = {};
1420
- imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function (arg0, arg1) {
1421
- throw new Error(getStringFromWasm0(arg0, arg1));
1422
- };
1423
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function (arg0, arg1) {
1424
- let deferred0_0;
1425
- let deferred0_1;
1426
- try {
1427
- deferred0_0 = arg0;
1428
- deferred0_1 = arg1;
1429
- console.error(getStringFromWasm0(arg0, arg1));
1430
- } finally {
1431
- wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
1432
- }
1433
- };
1434
- imports.wbg.__wbg_getTime_14776bfb48a1bff9 = function (arg0) {
1435
- const ret = getObject(arg0).getTime();
1436
- return ret;
1437
- };
1438
- imports.wbg.__wbg_log_8cec76766b8c0e33 = function (arg0) {
1439
- console.log(getObject(arg0));
1440
- };
1441
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function () {
1442
- const ret = new Error();
1443
- return addHeapObject(ret);
1444
- };
1445
- imports.wbg.__wbg_new_93d9417ed3fb115d = function (arg0) {
1446
- const ret = new Date(getObject(arg0));
1447
- return addHeapObject(ret);
1448
- };
1449
- imports.wbg.__wbg_now_793306c526e2e3b6 = function () {
1450
- const ret = Date.now();
1451
- return ret;
1452
- };
1453
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function (arg0, arg1) {
1454
- const ret = getObject(arg1).stack;
1455
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
1456
- const len1 = WASM_VECTOR_LEN;
1457
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1458
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1459
- };
1460
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function (arg0, arg1) {
1461
- // Cast intrinsic for `Ref(String) -> Externref`.
1462
- const ret = getStringFromWasm0(arg0, arg1);
1463
- return addHeapObject(ret);
1464
- };
1465
- imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
1466
- takeObject(arg0);
1467
- };
1468
-
1469
- return imports;
504
+ const imports = {};
505
+ imports.wbg = {};
506
+ imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function() { return logError(function (arg0, arg1) {
507
+ let deferred0_0;
508
+ let deferred0_1;
509
+ try {
510
+ deferred0_0 = arg0;
511
+ deferred0_1 = arg1;
512
+ console.error(getStringFromWasm0(arg0, arg1));
513
+ } finally {
514
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
515
+ }
516
+ }, arguments) };
517
+ imports.wbg.__wbg_getTime_46267b1c24877e30 = function() { return logError(function (arg0) {
518
+ const ret = arg0.getTime();
519
+ return ret;
520
+ }, arguments) };
521
+ imports.wbg.__wbg_log_c222819a41e063d3 = function() { return logError(function (arg0) {
522
+ console.log(arg0);
523
+ }, arguments) };
524
+ imports.wbg.__wbg_new_31a97dac4f10fab7 = function() { return logError(function (arg0) {
525
+ const ret = new Date(arg0);
526
+ return ret;
527
+ }, arguments) };
528
+ imports.wbg.__wbg_new_8a6f238a6ece86ea = function() { return logError(function () {
529
+ const ret = new Error();
530
+ return ret;
531
+ }, arguments) };
532
+ imports.wbg.__wbg_now_807e54c39636c349 = function() { return logError(function () {
533
+ const ret = Date.now();
534
+ return ret;
535
+ }, arguments) };
536
+ imports.wbg.__wbg_stack_0ed75d68575b0f3c = function() { return logError(function (arg0, arg1) {
537
+ const ret = arg1.stack;
538
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
539
+ const len1 = WASM_VECTOR_LEN;
540
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
541
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
542
+ }, arguments) };
543
+ imports.wbg.__wbindgen_init_externref_table = function() {
544
+ const table = wasm.__wbindgen_export_3;
545
+ const offset = table.grow(4);
546
+ table.set(0, undefined);
547
+ table.set(offset + 0, undefined);
548
+ table.set(offset + 1, null);
549
+ table.set(offset + 2, true);
550
+ table.set(offset + 3, false);
551
+ ;
552
+ };
553
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
554
+ const ret = getStringFromWasm0(arg0, arg1);
555
+ return ret;
556
+ };
557
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
558
+ throw new Error(getStringFromWasm0(arg0, arg1));
559
+ };
560
+
561
+ return imports;
562
+ }
563
+
564
+ function __wbg_init_memory(imports, memory) {
565
+
1470
566
  }
1471
567
 
1472
568
  function __wbg_finalize_init(instance, module) {
1473
- wasm = instance.exports;
1474
- __wbg_init.__wbindgen_wasm_module = module;
1475
- cachedDataViewMemory0 = null;
1476
- cachedUint8ArrayMemory0 = null;
569
+ wasm = instance.exports;
570
+ __wbg_init.__wbindgen_wasm_module = module;
571
+ cachedDataViewMemory0 = null;
572
+ cachedUint8ArrayMemory0 = null;
573
+
1477
574
 
1478
- wasm.__wbindgen_start();
1479
- return wasm;
575
+ wasm.__wbindgen_start();
576
+ return wasm;
1480
577
  }
1481
578
 
1482
579
  function initSync(module) {
1483
- if (wasm !== undefined) return wasm;
580
+ if (wasm !== undefined) return wasm;
1484
581
 
1485
- if (typeof module !== 'undefined') {
1486
- if (Object.getPrototypeOf(module) === Object.prototype) {
1487
- ({ module } = module);
1488
- } else {
1489
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead');
582
+
583
+ if (typeof module !== 'undefined') {
584
+ if (Object.getPrototypeOf(module) === Object.prototype) {
585
+ ({module} = module)
586
+ } else {
587
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
588
+ }
1490
589
  }
1491
- }
1492
590
 
1493
- const imports = __wbg_get_imports();
591
+ const imports = __wbg_get_imports();
1494
592
 
1495
- if (!(module instanceof WebAssembly.Module)) {
1496
- module = new WebAssembly.Module(module);
1497
- }
593
+ __wbg_init_memory(imports);
594
+
595
+ if (!(module instanceof WebAssembly.Module)) {
596
+ module = new WebAssembly.Module(module);
597
+ }
1498
598
 
1499
- const instance = new WebAssembly.Instance(module, imports);
599
+ const instance = new WebAssembly.Instance(module, imports);
1500
600
 
1501
- return __wbg_finalize_init(instance, module);
601
+ return __wbg_finalize_init(instance, module);
1502
602
  }
1503
603
 
1504
604
  async function __wbg_init(module_or_path) {
1505
- if (wasm !== undefined) return wasm;
605
+ if (wasm !== undefined) return wasm;
1506
606
 
1507
- if (typeof module_or_path !== 'undefined') {
1508
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1509
- ({ module_or_path } = module_or_path);
1510
- } else {
1511
- console.warn(
1512
- 'using deprecated parameters for the initialization function; pass a single object instead'
1513
- );
607
+
608
+ if (typeof module_or_path !== 'undefined') {
609
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
610
+ ({module_or_path} = module_or_path)
611
+ } else {
612
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
613
+ }
1514
614
  }
1515
- }
1516
615
 
1517
- if (typeof module_or_path === 'undefined') {
1518
- module_or_path = new URL('agentshield_wasm_bg.wasm', import.meta.url);
1519
- }
1520
- const imports = __wbg_get_imports();
616
+ if (typeof module_or_path === 'undefined') {
617
+ module_or_path = new URL('agentshield_wasm_bg.wasm', import.meta.url);
618
+ }
619
+ const imports = __wbg_get_imports();
620
+
621
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
622
+ module_or_path = fetch(module_or_path);
623
+ }
1521
624
 
1522
- if (
1523
- typeof module_or_path === 'string' ||
1524
- (typeof Request === 'function' && module_or_path instanceof Request) ||
1525
- (typeof URL === 'function' && module_or_path instanceof URL)
1526
- ) {
1527
- module_or_path = fetch(module_or_path);
1528
- }
625
+ __wbg_init_memory(imports);
1529
626
 
1530
- const { instance, module } = await __wbg_load(await module_or_path, imports);
627
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1531
628
 
1532
- return __wbg_finalize_init(instance, module);
629
+ return __wbg_finalize_init(instance, module);
1533
630
  }
1534
631
 
1535
632
  export { initSync };