@kya-os/agentshield-nextjs 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/create-middleware.js +2 -28
- package/dist/create-middleware.js.map +1 -1
- package/dist/create-middleware.mjs +2 -28
- package/dist/create-middleware.mjs.map +1 -1
- package/dist/edge-wasm-middleware.d.mts +10 -1
- package/dist/edge-wasm-middleware.d.ts +10 -1
- package/dist/edge-wasm-middleware.js +76 -12
- package/dist/edge-wasm-middleware.js.map +1 -1
- package/dist/edge-wasm-middleware.mjs +76 -12
- package/dist/edge-wasm-middleware.mjs.map +1 -1
- package/dist/enhanced-middleware.js +2 -28
- package/dist/enhanced-middleware.js.map +1 -1
- package/dist/enhanced-middleware.mjs +2 -28
- package/dist/enhanced-middleware.mjs.map +1 -1
- package/dist/index.js +2 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -28
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.js +2 -28
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +2 -28
- package/dist/middleware.mjs.map +1 -1
- package/package.json +1 -1
- package/wasm/agentshield_wasm.d.ts +6 -33
- package/wasm/agentshield_wasm.js +209 -284
- package/wasm/agentshield_wasm_bg.wasm +0 -0
package/wasm/agentshield_wasm.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
let wasm;
|
|
2
2
|
|
|
3
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
4
|
+
|
|
5
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
6
|
+
|
|
3
7
|
let cachedUint8ArrayMemory0 = null;
|
|
4
8
|
|
|
5
9
|
function getUint8ArrayMemory0() {
|
|
@@ -9,61 +13,48 @@ function getUint8ArrayMemory0() {
|
|
|
9
13
|
return cachedUint8ArrayMemory0;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
13
|
-
|
|
14
|
-
cachedTextDecoder.decode();
|
|
15
|
-
|
|
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));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
16
|
function getStringFromWasm0(ptr, len) {
|
|
29
17
|
ptr = ptr >>> 0;
|
|
30
|
-
return
|
|
18
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
31
19
|
}
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
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
|
+
}
|
|
48
35
|
}
|
|
49
36
|
|
|
50
37
|
let WASM_VECTOR_LEN = 0;
|
|
51
38
|
|
|
52
|
-
const cachedTextEncoder = new TextEncoder();
|
|
39
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
53
40
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
view.set(buf);
|
|
58
|
-
return {
|
|
59
|
-
read: arg.length,
|
|
60
|
-
written: buf.length
|
|
61
|
-
};
|
|
62
|
-
}
|
|
41
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
42
|
+
? function (arg, view) {
|
|
43
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
63
44
|
}
|
|
45
|
+
: function (arg, view) {
|
|
46
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
47
|
+
view.set(buf);
|
|
48
|
+
return {
|
|
49
|
+
read: arg.length,
|
|
50
|
+
written: buf.length
|
|
51
|
+
};
|
|
52
|
+
});
|
|
64
53
|
|
|
65
54
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
66
55
|
|
|
56
|
+
if (typeof(arg) !== 'string') throw new Error(`expected a string argument, found ${typeof(arg)}`);
|
|
57
|
+
|
|
67
58
|
if (realloc === undefined) {
|
|
68
59
|
const buf = cachedTextEncoder.encode(arg);
|
|
69
60
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
@@ -91,8 +82,8 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
91
82
|
}
|
|
92
83
|
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
93
84
|
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
94
|
-
const ret =
|
|
95
|
-
|
|
85
|
+
const ret = encodeString(arg, view);
|
|
86
|
+
if (ret.read !== arg.length) throw new Error('failed to pass whole string');
|
|
96
87
|
offset += ret.written;
|
|
97
88
|
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
98
89
|
}
|
|
@@ -110,16 +101,14 @@ function getDataViewMemory0() {
|
|
|
110
101
|
return cachedDataViewMemory0;
|
|
111
102
|
}
|
|
112
103
|
|
|
113
|
-
function
|
|
114
|
-
if (
|
|
115
|
-
heap[idx] = heap_next;
|
|
116
|
-
heap_next = idx;
|
|
104
|
+
function _assertNum(n) {
|
|
105
|
+
if (typeof(n) !== 'number') throw new Error(`expected a number argument, found ${typeof(n)}`);
|
|
117
106
|
}
|
|
118
107
|
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
function _assertBoolean(n) {
|
|
109
|
+
if (typeof(n) !== 'boolean') {
|
|
110
|
+
throw new Error(`expected a boolean argument, found ${typeof(n)}`);
|
|
111
|
+
}
|
|
123
112
|
}
|
|
124
113
|
|
|
125
114
|
function isLikeNone(x) {
|
|
@@ -137,88 +126,43 @@ function _assertClass(instance, klass) {
|
|
|
137
126
|
throw new Error(`expected instance of ${klass.name}`);
|
|
138
127
|
}
|
|
139
128
|
}
|
|
129
|
+
|
|
130
|
+
function takeFromExternrefTable0(idx) {
|
|
131
|
+
const value = wasm.__wbindgen_export_3.get(idx);
|
|
132
|
+
wasm.__externref_table_dealloc(idx);
|
|
133
|
+
return value;
|
|
134
|
+
}
|
|
140
135
|
/**
|
|
141
136
|
* Analyze a request and detect if it's from an agent
|
|
142
137
|
* @param {JsRequestMetadata} metadata
|
|
143
138
|
* @returns {JsDetectionResult}
|
|
144
139
|
*/
|
|
145
140
|
export function detect_agent(metadata) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
wasm.detect_agent(retptr, metadata.__wbg_ptr);
|
|
150
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
151
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
152
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
153
|
-
if (r2) {
|
|
154
|
-
throw takeObject(r1);
|
|
155
|
-
}
|
|
156
|
-
return JsDetectionResult.__wrap(r0);
|
|
157
|
-
} finally {
|
|
158
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
141
|
+
_assertClass(metadata, JsRequestMetadata);
|
|
142
|
+
if (metadata.__wbg_ptr === 0) {
|
|
143
|
+
throw new Error('Attempt to use a moved value');
|
|
159
144
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
* Get the version of the AgentShield library
|
|
164
|
-
* @returns {string}
|
|
165
|
-
*/
|
|
166
|
-
export function version() {
|
|
167
|
-
let deferred1_0;
|
|
168
|
-
let deferred1_1;
|
|
169
|
-
try {
|
|
170
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
171
|
-
wasm.get_version(retptr);
|
|
172
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
173
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
174
|
-
deferred1_0 = r0;
|
|
175
|
-
deferred1_1 = r1;
|
|
176
|
-
return getStringFromWasm0(r0, r1);
|
|
177
|
-
} finally {
|
|
178
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
179
|
-
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
145
|
+
const ret = wasm.detect_agent(metadata.__wbg_ptr);
|
|
146
|
+
if (ret[2]) {
|
|
147
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
180
148
|
}
|
|
149
|
+
return JsDetectionResult.__wrap(ret[0]);
|
|
181
150
|
}
|
|
182
151
|
|
|
183
152
|
/**
|
|
184
153
|
* Get the version of the AgentShield library
|
|
185
154
|
* @returns {string}
|
|
186
155
|
*/
|
|
187
|
-
export function
|
|
188
|
-
let deferred1_0;
|
|
189
|
-
let deferred1_1;
|
|
190
|
-
try {
|
|
191
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
192
|
-
wasm.get_version(retptr);
|
|
193
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
194
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
195
|
-
deferred1_0 = r0;
|
|
196
|
-
deferred1_1 = r1;
|
|
197
|
-
return getStringFromWasm0(r0, r1);
|
|
198
|
-
} finally {
|
|
199
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
200
|
-
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Get build information
|
|
206
|
-
* @returns {string}
|
|
207
|
-
*/
|
|
208
|
-
export function get_build_info() {
|
|
156
|
+
export function version() {
|
|
209
157
|
let deferred1_0;
|
|
210
158
|
let deferred1_1;
|
|
211
159
|
try {
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
deferred1_0 = r0;
|
|
217
|
-
deferred1_1 = r1;
|
|
218
|
-
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]);
|
|
219
164
|
} finally {
|
|
220
|
-
wasm.
|
|
221
|
-
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
165
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
222
166
|
}
|
|
223
167
|
}
|
|
224
168
|
|
|
@@ -230,6 +174,10 @@ const JsDetectionResultFinalization = (typeof FinalizationRegistry === 'undefine
|
|
|
230
174
|
*/
|
|
231
175
|
export class JsDetectionResult {
|
|
232
176
|
|
|
177
|
+
constructor() {
|
|
178
|
+
throw new Error('cannot invoke `new` directly');
|
|
179
|
+
}
|
|
180
|
+
|
|
233
181
|
static __wrap(ptr) {
|
|
234
182
|
ptr = ptr >>> 0;
|
|
235
183
|
const obj = Object.create(JsDetectionResult.prototype);
|
|
@@ -254,6 +202,8 @@ export class JsDetectionResult {
|
|
|
254
202
|
* @returns {boolean}
|
|
255
203
|
*/
|
|
256
204
|
get is_agent() {
|
|
205
|
+
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
206
|
+
_assertNum(this.__wbg_ptr);
|
|
257
207
|
const ret = wasm.__wbg_get_jsdetectionresult_is_agent(this.__wbg_ptr);
|
|
258
208
|
return ret !== 0;
|
|
259
209
|
}
|
|
@@ -262,21 +212,28 @@ export class JsDetectionResult {
|
|
|
262
212
|
* @param {boolean} arg0
|
|
263
213
|
*/
|
|
264
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);
|
|
265
218
|
wasm.__wbg_set_jsdetectionresult_is_agent(this.__wbg_ptr, arg0);
|
|
266
219
|
}
|
|
267
220
|
/**
|
|
268
|
-
* Confidence score (0
|
|
221
|
+
* Confidence score (0.0 to 1.0)
|
|
269
222
|
* @returns {number}
|
|
270
223
|
*/
|
|
271
224
|
get confidence() {
|
|
225
|
+
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
226
|
+
_assertNum(this.__wbg_ptr);
|
|
272
227
|
const ret = wasm.__wbg_get_jsdetectionresult_confidence(this.__wbg_ptr);
|
|
273
228
|
return ret;
|
|
274
229
|
}
|
|
275
230
|
/**
|
|
276
|
-
* Confidence score (0
|
|
231
|
+
* Confidence score (0.0 to 1.0)
|
|
277
232
|
* @param {number} arg0
|
|
278
233
|
*/
|
|
279
234
|
set confidence(arg0) {
|
|
235
|
+
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
|
236
|
+
_assertNum(this.__wbg_ptr);
|
|
280
237
|
wasm.__wbg_set_jsdetectionresult_confidence(this.__wbg_ptr, arg0);
|
|
281
238
|
}
|
|
282
239
|
/**
|
|
@@ -284,20 +241,15 @@ export class JsDetectionResult {
|
|
|
284
241
|
* @returns {string | undefined}
|
|
285
242
|
*/
|
|
286
243
|
get agent() {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
295
|
-
wasm.__wbindgen_export(r0, r1 * 1, 1);
|
|
296
|
-
}
|
|
297
|
-
return v1;
|
|
298
|
-
} finally {
|
|
299
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
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);
|
|
300
251
|
}
|
|
252
|
+
return v1;
|
|
301
253
|
}
|
|
302
254
|
/**
|
|
303
255
|
* Get the verification method as a string
|
|
@@ -307,16 +259,14 @@ export class JsDetectionResult {
|
|
|
307
259
|
let deferred1_0;
|
|
308
260
|
let deferred1_1;
|
|
309
261
|
try {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return getStringFromWasm0(r0, r1);
|
|
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]);
|
|
317
268
|
} finally {
|
|
318
|
-
wasm.
|
|
319
|
-
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
269
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
320
270
|
}
|
|
321
271
|
}
|
|
322
272
|
/**
|
|
@@ -327,16 +277,14 @@ export class JsDetectionResult {
|
|
|
327
277
|
let deferred1_0;
|
|
328
278
|
let deferred1_1;
|
|
329
279
|
try {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
return getStringFromWasm0(r0, r1);
|
|
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]);
|
|
337
286
|
} finally {
|
|
338
|
-
wasm.
|
|
339
|
-
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
287
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
340
288
|
}
|
|
341
289
|
}
|
|
342
290
|
/**
|
|
@@ -347,20 +295,17 @@ export class JsDetectionResult {
|
|
|
347
295
|
let deferred1_0;
|
|
348
296
|
let deferred1_1;
|
|
349
297
|
try {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
return getStringFromWasm0(r0, r1);
|
|
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]);
|
|
357
304
|
} finally {
|
|
358
|
-
wasm.
|
|
359
|
-
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
305
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
360
306
|
}
|
|
361
307
|
}
|
|
362
308
|
}
|
|
363
|
-
if (Symbol.dispose) JsDetectionResult.prototype[Symbol.dispose] = JsDetectionResult.prototype.free;
|
|
364
309
|
|
|
365
310
|
const JsRequestMetadataFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
366
311
|
? { register: () => {}, unregister: () => {} }
|
|
@@ -392,19 +337,19 @@ export class JsRequestMetadata {
|
|
|
392
337
|
* @param {string | null} [client_fingerprint]
|
|
393
338
|
*/
|
|
394
339
|
constructor(user_agent, ip_address, headers, timestamp, url, method, client_fingerprint) {
|
|
395
|
-
var ptr0 = isLikeNone(user_agent) ? 0 : passStringToWasm0(user_agent, wasm.
|
|
340
|
+
var ptr0 = isLikeNone(user_agent) ? 0 : passStringToWasm0(user_agent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
396
341
|
var len0 = WASM_VECTOR_LEN;
|
|
397
|
-
var ptr1 = isLikeNone(ip_address) ? 0 : passStringToWasm0(ip_address, wasm.
|
|
342
|
+
var ptr1 = isLikeNone(ip_address) ? 0 : passStringToWasm0(ip_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
398
343
|
var len1 = WASM_VECTOR_LEN;
|
|
399
|
-
const ptr2 = passStringToWasm0(headers, wasm.
|
|
344
|
+
const ptr2 = passStringToWasm0(headers, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
400
345
|
const len2 = WASM_VECTOR_LEN;
|
|
401
|
-
const ptr3 = passStringToWasm0(timestamp, wasm.
|
|
346
|
+
const ptr3 = passStringToWasm0(timestamp, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
402
347
|
const len3 = WASM_VECTOR_LEN;
|
|
403
|
-
var ptr4 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.
|
|
348
|
+
var ptr4 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
404
349
|
var len4 = WASM_VECTOR_LEN;
|
|
405
|
-
var ptr5 = isLikeNone(method) ? 0 : passStringToWasm0(method, wasm.
|
|
350
|
+
var ptr5 = isLikeNone(method) ? 0 : passStringToWasm0(method, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
406
351
|
var len5 = WASM_VECTOR_LEN;
|
|
407
|
-
var ptr6 = isLikeNone(client_fingerprint) ? 0 : passStringToWasm0(client_fingerprint, wasm.
|
|
352
|
+
var ptr6 = isLikeNone(client_fingerprint) ? 0 : passStringToWasm0(client_fingerprint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
408
353
|
var len6 = WASM_VECTOR_LEN;
|
|
409
354
|
const ret = wasm.jsrequestmetadata_new(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
|
|
410
355
|
this.__wbg_ptr = ret >>> 0;
|
|
@@ -416,40 +361,30 @@ export class JsRequestMetadata {
|
|
|
416
361
|
* @returns {string | undefined}
|
|
417
362
|
*/
|
|
418
363
|
get user_agent() {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
427
|
-
wasm.__wbindgen_export(r0, r1 * 1, 1);
|
|
428
|
-
}
|
|
429
|
-
return v1;
|
|
430
|
-
} finally {
|
|
431
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
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);
|
|
432
371
|
}
|
|
372
|
+
return v1;
|
|
433
373
|
}
|
|
434
374
|
/**
|
|
435
375
|
* Get the IP address
|
|
436
376
|
* @returns {string | undefined}
|
|
437
377
|
*/
|
|
438
378
|
get ip_address() {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
447
|
-
wasm.__wbindgen_export(r0, r1 * 1, 1);
|
|
448
|
-
}
|
|
449
|
-
return v1;
|
|
450
|
-
} finally {
|
|
451
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
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);
|
|
452
386
|
}
|
|
387
|
+
return v1;
|
|
453
388
|
}
|
|
454
389
|
/**
|
|
455
390
|
* Get the headers as JSON string
|
|
@@ -459,16 +394,14 @@ export class JsRequestMetadata {
|
|
|
459
394
|
let deferred1_0;
|
|
460
395
|
let deferred1_1;
|
|
461
396
|
try {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
return getStringFromWasm0(r0, r1);
|
|
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]);
|
|
469
403
|
} finally {
|
|
470
|
-
wasm.
|
|
471
|
-
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
404
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
472
405
|
}
|
|
473
406
|
}
|
|
474
407
|
/**
|
|
@@ -479,16 +412,14 @@ export class JsRequestMetadata {
|
|
|
479
412
|
let deferred1_0;
|
|
480
413
|
let deferred1_1;
|
|
481
414
|
try {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
return getStringFromWasm0(r0, r1);
|
|
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]);
|
|
489
421
|
} finally {
|
|
490
|
-
wasm.
|
|
491
|
-
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
422
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
492
423
|
}
|
|
493
424
|
}
|
|
494
425
|
/**
|
|
@@ -496,65 +427,47 @@ export class JsRequestMetadata {
|
|
|
496
427
|
* @returns {string | undefined}
|
|
497
428
|
*/
|
|
498
429
|
get url() {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
507
|
-
wasm.__wbindgen_export(r0, r1 * 1, 1);
|
|
508
|
-
}
|
|
509
|
-
return v1;
|
|
510
|
-
} finally {
|
|
511
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
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);
|
|
512
437
|
}
|
|
438
|
+
return v1;
|
|
513
439
|
}
|
|
514
440
|
/**
|
|
515
441
|
* Get the method
|
|
516
442
|
* @returns {string | undefined}
|
|
517
443
|
*/
|
|
518
444
|
get method() {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
527
|
-
wasm.__wbindgen_export(r0, r1 * 1, 1);
|
|
528
|
-
}
|
|
529
|
-
return v1;
|
|
530
|
-
} finally {
|
|
531
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
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);
|
|
532
452
|
}
|
|
453
|
+
return v1;
|
|
533
454
|
}
|
|
534
455
|
/**
|
|
535
456
|
* Get the client fingerprint
|
|
536
457
|
* @returns {string | undefined}
|
|
537
458
|
*/
|
|
538
459
|
get client_fingerprint() {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
547
|
-
wasm.__wbindgen_export(r0, r1 * 1, 1);
|
|
548
|
-
}
|
|
549
|
-
return v1;
|
|
550
|
-
} finally {
|
|
551
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
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);
|
|
552
467
|
}
|
|
468
|
+
return v1;
|
|
553
469
|
}
|
|
554
470
|
}
|
|
555
|
-
if (Symbol.dispose) JsRequestMetadata.prototype[Symbol.dispose] = JsRequestMetadata.prototype.free;
|
|
556
|
-
|
|
557
|
-
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
558
471
|
|
|
559
472
|
async function __wbg_load(module, imports) {
|
|
560
473
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
@@ -563,9 +476,7 @@ async function __wbg_load(module, imports) {
|
|
|
563
476
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
564
477
|
|
|
565
478
|
} catch (e) {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
479
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
569
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);
|
|
570
481
|
|
|
571
482
|
} else {
|
|
@@ -592,10 +503,7 @@ async function __wbg_load(module, imports) {
|
|
|
592
503
|
function __wbg_get_imports() {
|
|
593
504
|
const imports = {};
|
|
594
505
|
imports.wbg = {};
|
|
595
|
-
imports.wbg.
|
|
596
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
597
|
-
};
|
|
598
|
-
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
506
|
+
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function() { return logError(function (arg0, arg1) {
|
|
599
507
|
let deferred0_0;
|
|
600
508
|
let deferred0_1;
|
|
601
509
|
try {
|
|
@@ -603,47 +511,60 @@ function __wbg_get_imports() {
|
|
|
603
511
|
deferred0_1 = arg1;
|
|
604
512
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
605
513
|
} finally {
|
|
606
|
-
wasm.
|
|
514
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
607
515
|
}
|
|
608
|
-
};
|
|
609
|
-
imports.wbg.
|
|
610
|
-
const ret =
|
|
516
|
+
}, arguments) };
|
|
517
|
+
imports.wbg.__wbg_getTime_46267b1c24877e30 = function() { return logError(function (arg0) {
|
|
518
|
+
const ret = arg0.getTime();
|
|
611
519
|
return ret;
|
|
612
|
-
};
|
|
613
|
-
imports.wbg.
|
|
614
|
-
console.log(
|
|
615
|
-
};
|
|
616
|
-
imports.wbg.
|
|
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 () {
|
|
617
529
|
const ret = new Error();
|
|
618
|
-
return
|
|
619
|
-
};
|
|
620
|
-
imports.wbg.
|
|
621
|
-
const ret = new Date(getObject(arg0));
|
|
622
|
-
return addHeapObject(ret);
|
|
623
|
-
};
|
|
624
|
-
imports.wbg.__wbg_now_793306c526e2e3b6 = function() {
|
|
530
|
+
return ret;
|
|
531
|
+
}, arguments) };
|
|
532
|
+
imports.wbg.__wbg_now_807e54c39636c349 = function() { return logError(function () {
|
|
625
533
|
const ret = Date.now();
|
|
626
534
|
return ret;
|
|
627
|
-
};
|
|
628
|
-
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
629
|
-
const ret =
|
|
630
|
-
const ptr1 = passStringToWasm0(ret, wasm.
|
|
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);
|
|
631
539
|
const len1 = WASM_VECTOR_LEN;
|
|
632
540
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
633
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
|
+
;
|
|
634
552
|
};
|
|
635
|
-
imports.wbg.
|
|
636
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
553
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
637
554
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
638
|
-
return
|
|
555
|
+
return ret;
|
|
639
556
|
};
|
|
640
|
-
imports.wbg.
|
|
641
|
-
|
|
557
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
558
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
642
559
|
};
|
|
643
560
|
|
|
644
561
|
return imports;
|
|
645
562
|
}
|
|
646
563
|
|
|
564
|
+
function __wbg_init_memory(imports, memory) {
|
|
565
|
+
|
|
566
|
+
}
|
|
567
|
+
|
|
647
568
|
function __wbg_finalize_init(instance, module) {
|
|
648
569
|
wasm = instance.exports;
|
|
649
570
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
@@ -669,6 +590,8 @@ function initSync(module) {
|
|
|
669
590
|
|
|
670
591
|
const imports = __wbg_get_imports();
|
|
671
592
|
|
|
593
|
+
__wbg_init_memory(imports);
|
|
594
|
+
|
|
672
595
|
if (!(module instanceof WebAssembly.Module)) {
|
|
673
596
|
module = new WebAssembly.Module(module);
|
|
674
597
|
}
|
|
@@ -699,6 +622,8 @@ async function __wbg_init(module_or_path) {
|
|
|
699
622
|
module_or_path = fetch(module_or_path);
|
|
700
623
|
}
|
|
701
624
|
|
|
625
|
+
__wbg_init_memory(imports);
|
|
626
|
+
|
|
702
627
|
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
703
628
|
|
|
704
629
|
return __wbg_finalize_init(instance, module);
|