@netacea/f5 4.3.123 → 4.3.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,549 @@
1
+ type KinesisMakeRequest = (args: {
2
+ headers: Record<string, string>;
3
+ method: 'POST' | 'GET';
4
+ host: string;
5
+ path: string;
6
+ body?: any;
7
+ }) => Promise<any>;
8
+ interface KinesisIngestWebLog {
9
+ apiKey: string;
10
+ }
11
+ interface KinesisIngestConfigArgs {
12
+ kinesisStreamName: string;
13
+ kinesisAccessKey?: string;
14
+ kinesisSecretKey?: string;
15
+ logBatchSize?: number;
16
+ maxLogAgeSeconds?: number;
17
+ }
18
+ interface KinesisIngestArgs extends KinesisIngestConfigArgs {
19
+ apiKey: string;
20
+ /**
21
+ * Gradually increase the batch size to reduce risk of lost batches.
22
+ * This is intended for user on aws lambdas, which have an unpredictable lifetime.
23
+ */
24
+ rampUpBatchSize?: boolean;
25
+ /**
26
+ * If a request triggest a POST to kinesis, then this is how maximum time
27
+ * the ingest method will wait for that request to finish.
28
+ * If undefined, then ingest will wait as long as needed ,until a batch is ingested.
29
+ */
30
+ maxAwaitTimePerIngestCallMs?: number;
31
+ }
32
+ declare class KinesisIngest {
33
+ protected readonly kinesisStreamName: string;
34
+ protected readonly kinesisAccessKey?: string;
35
+ protected readonly kinesisSecretKey?: string;
36
+ protected readonly maxLogBatchSize: number;
37
+ protected readonly maxLogAgeSeconds: number;
38
+ protected logBatchSize: number;
39
+ protected maxAwaitTimePerIngestCallMs: undefined | number;
40
+ protected logCache: KinesisIngestWebLog[];
41
+ private intervalSet;
42
+ constructor({ kinesisStreamName, kinesisAccessKey, kinesisSecretKey, maxLogAgeSeconds, logBatchSize, rampUpBatchSize, maxAwaitTimePerIngestCallMs }: KinesisIngestArgs);
43
+ putToKinesis<MakeRequest extends KinesisMakeRequest>(makeRequest: MakeRequest): Promise<void>;
44
+ ingest<LogFormat extends KinesisIngestWebLog, MakeRequest extends KinesisMakeRequest>(log: LogFormat, makeRequest: MakeRequest): Promise<void>;
45
+ }
46
+
47
+ declare enum NetaceaIngestType {
48
+ /**
49
+ * ORIGIN Ingest mode; data to be ingested is set by headers, so it can be forwarded via a seperate mechanism
50
+ */
51
+ ORIGIN = "ORIGIN",
52
+ /**
53
+ * HTTP Ingest mode, this is the standard implementation
54
+ */
55
+ HTTP = "HTTP",
56
+ /**
57
+ * Ingest over Kinesis, Netacea will inform you if this is required
58
+ * and will provide you with kinesis credentials.
59
+ */
60
+ KINESIS = "KINESIS",
61
+ /**
62
+ * Data to be Ingest via some mechanism native to the host/CDN, e.g. log shipping.
63
+ */
64
+ NATIVE = "NATIVE"
65
+ }
66
+ declare enum NetaceaMitigationType {
67
+ /**
68
+ * Run Netacea with mitigation mode enabled.
69
+ * This will serve Captcha pages and Forbidden pages when instructed to do so
70
+ */
71
+ MITIGATE = "MITIGATE",
72
+ /**
73
+ * Run Netacea with Inject mode enabled.
74
+ * The end-user will only receive a cookie.
75
+ * The origin server will receive 3-4 headers,
76
+ *
77
+ * 'x-netacea-match' indicating what was matched (nothing(0), ua(1), ip(2), etc...)
78
+ *
79
+ * 'x-netacea-mitigate' indicating what action would've be taken (nothing (0), block(1), allow(2), etc...)
80
+ *
81
+ * 'x-netacea-captcha' indicating what captcha action would've been taken
82
+ *
83
+ * 'x-netacea-event-id' event id value that should be injected to the captcha
84
+ * page if using `@netacea/captchafeedback` module on the origin server
85
+ */
86
+ INJECT = "INJECT",
87
+ /**
88
+ * Run Netacea with Ingest only mode
89
+ * No cookies will be set for the end user.
90
+ * No mitigations will be applied.
91
+ *
92
+ * **It's recommended to start in this mode!**
93
+ */
94
+ INGEST = "INGEST"
95
+ }
96
+
97
+ interface MakeRequestArgs {
98
+ /**
99
+ * Hostname of the request. For example https://mitigations.netacea.net
100
+ */
101
+ host: string;
102
+ /**
103
+ * Path for the request, i.e captcha requests will be `/AtaVerifyCaptcha`
104
+ */
105
+ path: string;
106
+ /**
107
+ * Key value collection of the request headers
108
+ */
109
+ headers: Record<string, string>;
110
+ /**
111
+ * HTTP Method
112
+ */
113
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
114
+ /**
115
+ * Request body value
116
+ */
117
+ body?: string;
118
+ /**
119
+ * Request timeout value in ms
120
+ */
121
+ timeout?: number;
122
+ /**
123
+ * Request URL parameters
124
+ */
125
+ params?: Record<string, string> | URLSearchParams;
126
+ }
127
+ interface MakeRequestResponse {
128
+ /**
129
+ * Numerical status code of the response
130
+ */
131
+ status: number;
132
+ /**
133
+ * Key value collection of the response headers
134
+ */
135
+ headers: Record<string, string>;
136
+ /**
137
+ * Response body value
138
+ */
139
+ body?: string;
140
+ }
141
+ interface NetaceaBaseArgs {
142
+ /**
143
+ * Netacea APIKey
144
+ */
145
+ apiKey: string;
146
+ /**
147
+ * Netacea Secret Key
148
+ */
149
+ secretKey: string;
150
+ /**
151
+ * Google RECaptcha Site Key.
152
+ * This is used for providing your own captcha values without updating these in the Netacea console.
153
+ */
154
+ captchaSiteKey?: string;
155
+ /**
156
+ * Google RECaptcha Secret Key.
157
+ * This is used for providing your own captcha values without updating these in the Netacea console.
158
+ */
159
+ captchaSecretKey?: string;
160
+ /**
161
+ * Request timeout in ms
162
+ */
163
+ timeout?: number;
164
+ /**
165
+ * URL of the Netacea ingest service.
166
+ * DEFAULT: https://ingest.netacea.net
167
+ */
168
+ ingestServiceUrl?: string;
169
+ /**
170
+ * URL of the Netacea mitigation service.
171
+ * DEFAULT: https://mitigations.netacea.net
172
+ */
173
+ mitigationServiceUrl?: string;
174
+ /**
175
+ * Type of mitigation applied, see the `NetaceaMitigationType` ENUM
176
+ * - INGEST - Ingest only mode, no mitigations applied
177
+ * - MITIGATION - Mitigation mode, active blocking/captcha rules will be applied.
178
+ * - INJECT - Inject mode, headers will be sent to your origin server
179
+ * indicating what actions Netacea would have taken.
180
+ * DEFAULT: NetaceaMitigationType.INGEST
181
+ */
182
+ mitigationType?: NetaceaMitigationType;
183
+ /**
184
+ * Type of ingest, see the `NetaceaIngestType` ENUM
185
+ * - HTTP - Ingest via HTTP.
186
+ * - KINESIS - Ingest via KINESIS
187
+ * DEFAULT: NetaceaIngestType.HTTP
188
+ */
189
+ ingestType?: NetaceaIngestType;
190
+ /**
191
+ * Kinesis ingest definition, see the `KinesisIngestConfigArgs` type.
192
+ * Only to be provided if ingestType is set to KINESIS.
193
+ * Netacea will provide you with the details for this stream.
194
+ */
195
+ kinesis?: KinesisIngestConfigArgs;
196
+ /**
197
+ * Deprecated: alias for netaceaCookieExpirySeconds.
198
+ * If both are set, netaceaCookieExpirySeconds is prefered.
199
+ * Seconds for the netacea cookie to be revalidated after.
200
+ */
201
+ mitataCookieExpirySeconds?: number;
202
+ /**
203
+ * Seconds for the netacea cookie to be revalidated after.
204
+ */
205
+ netaceaCookieExpirySeconds?: number;
206
+ /**
207
+ * The name of the netacea cookie. Defaults to _mitata.
208
+ */
209
+ netaceaCookieName?: string;
210
+ /**
211
+ * The name of the netacea captcha cookie. Defaults to _mitatacaptcha.
212
+ */
213
+ netaceaCaptchaCookieName?: string;
214
+ }
215
+ interface InjectHeaders {
216
+ 'x-netacea-match': string;
217
+ 'x-netacea-mitigate': string;
218
+ 'x-netacea-captcha': string;
219
+ 'x-netacea-event-id'?: string;
220
+ }
221
+ interface ComposeResultResponse {
222
+ /**
223
+ * Body value of the response, should be in text format
224
+ */
225
+ body?: string;
226
+ /**
227
+ * Response status code
228
+ */
229
+ apiCallStatus?: number;
230
+ /**
231
+ * Response latency
232
+ */
233
+ apiCallLatency?: number;
234
+ /**
235
+ * setCookie values
236
+ */
237
+ setCookie: string[];
238
+ /**
239
+ * Netacea session status string for ingest
240
+ */
241
+ sessionStatus: string;
242
+ /**
243
+ * Netacea mitigation string
244
+ */
245
+ mitigation: string;
246
+ /**
247
+ * Indicates if response should be mitigated or not
248
+ */
249
+ mitigated: boolean;
250
+ /**
251
+ * Headers to ingest to origin server
252
+ */
253
+ injectHeaders?: InjectHeaders;
254
+ }
255
+ interface IngestArgs {
256
+ /**
257
+ * Client IP Address
258
+ */
259
+ ip: string;
260
+ /**
261
+ * Client User-Agent header value
262
+ */
263
+ userAgent: string;
264
+ /**
265
+ * Response status code
266
+ * Should be 403 if Netacea mitigated
267
+ */
268
+ status: string;
269
+ /**
270
+ * Request method
271
+ */
272
+ method: string;
273
+ /**
274
+ * Request path
275
+ */
276
+ path: string;
277
+ /**
278
+ * Request protocol
279
+ */
280
+ protocol: string | null;
281
+ /**
282
+ * Request referer header value
283
+ */
284
+ referer: string;
285
+ /**
286
+ * Request content-length header, or body size
287
+ */
288
+ bytesSent: string | number;
289
+ /**
290
+ * The time the request was started, in unix milliseconds format.
291
+ */
292
+ timeUnixMsUTC?: number;
293
+ /**
294
+ * Time taken to serve request
295
+ */
296
+ requestTime: string | number;
297
+ /**
298
+ * Netacea mitata cookie value.
299
+ * Should be request's cookie value if Netacea was not called.
300
+ */
301
+ mitataCookie?: string;
302
+ /**
303
+ * Session status from `ComposeResultResponse`
304
+ */
305
+ sessionStatus?: string;
306
+ /**
307
+ * Type of the integration, for example "Cloudflare" or "Cloudfront"
308
+ */
309
+ integrationType?: string;
310
+ /**
311
+ * SEMVER string indicating the version of the integration
312
+ * Example: 1.2.3
313
+ */
314
+ integrationVersion?: string;
315
+ /**
316
+ * IP values set by a CDN under "x-forwarded-for" header
317
+ */
318
+ cookieFingerprint?: string;
319
+ headerFingerprint?: string;
320
+ integrationMode?: string;
321
+ ipHeader?: string;
322
+ mitigationLatency?: number;
323
+ mitigationStatus?: number;
324
+ netaceaCookieStatus?: number;
325
+ requestHost?: string;
326
+ requestId?: string;
327
+ workerInstanceId?: string;
328
+ xForwardedFor?: string;
329
+ }
330
+ interface WebLog {
331
+ BytesSent: string;
332
+ HeaderHash?: string;
333
+ IntegrationType?: string;
334
+ IntegrationVersion?: string;
335
+ IpFromHeader?: string;
336
+ NetaceaMitigationApplied: string;
337
+ NetaceaUserIdCookie: string;
338
+ NetaceaUserIdCookieStatus?: number;
339
+ optional?: Record<string, unknown>;
340
+ ProtectionMode?: string;
341
+ ProtectorLatencyMs?: number;
342
+ ProtectorStatus?: number;
343
+ RealIp: string;
344
+ Referer: string;
345
+ Request: string;
346
+ RequestHost?: string;
347
+ RequestId?: string;
348
+ RequestTime: string;
349
+ Status: string;
350
+ TimeLocal: string;
351
+ TimeUnixMsUTC?: number;
352
+ UserAgent: string;
353
+ WorkerInstanceId?: string;
354
+ XForwardedFor?: string;
355
+ }
356
+ interface NetaceaResponseBase {
357
+ /**
358
+ * Cookies that should be set back to the user.
359
+ */
360
+ setCookie?: string[];
361
+ /**
362
+ * Netacea session status string
363
+ */
364
+ sessionStatus: string;
365
+ apiCallLatency?: number;
366
+ apiCallStatus?: number;
367
+ cookieSessionStatus?: string | undefined;
368
+ }
369
+ interface MitigateResponse<T = any> extends NetaceaResponseBase {
370
+ /**
371
+ * Response value, using Response generic
372
+ */
373
+ response?: T;
374
+ }
375
+ interface InjectResponse<T = any> extends MitigateResponse<T> {
376
+ /**
377
+ * Headers to be sent to the origin server
378
+ * X-Netacea-Match
379
+ * X-Netacea-Mitigate
380
+ * X-Netacea-Captcha
381
+ * X-Netacea-Event-ID (Only sent when CAPTCHA is served)
382
+ */
383
+ injectHeaders: InjectHeaders | undefined;
384
+ /**
385
+ * Response value, using Response generic
386
+ */
387
+ response?: T | undefined;
388
+ }
389
+ type NetaceaMitigationResponse<T> = MitigateResponse<T> | InjectResponse<T> | undefined;
390
+ interface NetaceaWorker<RequestArgs, Response> {
391
+ runMitigation: (args: RequestArgs) => Promise<NetaceaMitigationResponse<Response>>;
392
+ ingest: (...args: any[]) => Promise<any>;
393
+ }
394
+ interface FindBestMitigationResponse {
395
+ sessionStatus: string;
396
+ mitigation: string;
397
+ parts: NetaceaParts;
398
+ }
399
+ interface NetaceaParts {
400
+ match: string;
401
+ mitigate: string;
402
+ captcha: string;
403
+ }
404
+ interface APICallResponse {
405
+ status: number;
406
+ body?: string;
407
+ }
408
+ interface ProcessMitigateRequestArgs {
409
+ url: string;
410
+ method: string;
411
+ mitata: string | undefined;
412
+ mitataCaptcha: string | undefined;
413
+ clientIp: string;
414
+ userAgent: string;
415
+ getBodyFn: () => Promise<string>;
416
+ }
417
+
418
+ interface F5ConstructorArgs extends NetaceaBaseArgs {
419
+ maxSockets?: number;
420
+ }
421
+ interface F5Response {
422
+ body?: string;
423
+ status: number;
424
+ apiCallStatus: number;
425
+ mitigation: string;
426
+ mitigated: boolean;
427
+ }
428
+ interface F5MitigateArgs {
429
+ ip: string;
430
+ userAgent: string;
431
+ url: string;
432
+ method: string;
433
+ mitataCookie?: string;
434
+ mitataCaptchaCookie?: string;
435
+ body?: any;
436
+ }
437
+ interface F5IngestArgs {
438
+ ip: string;
439
+ userAgent: string;
440
+ status: string;
441
+ method: string;
442
+ path: string;
443
+ protocol: string;
444
+ referer: string;
445
+ bytesSent: string;
446
+ requestTime: string;
447
+ mitataCookie?: string;
448
+ sessionStatus?: string;
449
+ }
450
+ type NetaceaF5InjectHeaders = [
451
+ string,
452
+ string,
453
+ string,
454
+ string
455
+ ] | [];
456
+ interface F5Request<T extends unknown[]> {
457
+ params: () => T;
458
+ }
459
+ interface F5Res {
460
+ reply: (args: [
461
+ string,
462
+ number,
463
+ string[],
464
+ string,
465
+ boolean,
466
+ string,
467
+ NetaceaF5InjectHeaders
468
+ ] | string) => void;
469
+ }
470
+ interface IlxServer {
471
+ addMethod: <T extends any[]>(handler: string, func: (req: F5Request<T>, res: F5Res) => Promise<void> | void) => void;
472
+ listen: () => void;
473
+ }
474
+ declare abstract class NetaceaBase<RequestArgs = unknown, Response = unknown> implements NetaceaWorker<RequestArgs, Response> {
475
+ protected mitataCookieExpirySeconds: number;
476
+ protected apiKey: string;
477
+ protected secretKey?: string;
478
+ protected mitigationServiceUrl: string;
479
+ protected ingestServiceUrl: string;
480
+ protected readonly timeout: number;
481
+ protected readonly captchaSiteKey?: string;
482
+ protected readonly captchaSecretKey?: string;
483
+ protected readonly ingestType: NetaceaIngestType;
484
+ protected readonly kinesis?: KinesisIngest;
485
+ protected readonly mitigationType: NetaceaMitigationType;
486
+ protected readonly encryptedCookies: string[];
487
+ protected readonly netaceaCookieName: string;
488
+ protected readonly netaceaCaptchaCookieName: string;
489
+ protected abstract makeRequest(args: MakeRequestArgs): Promise<MakeRequestResponse>;
490
+ protected abstract mitigate(args: RequestArgs): Promise<MitigateResponse<Response>>;
491
+ protected abstract inject(args: RequestArgs): Promise<InjectResponse>;
492
+ abstract ingest(...args: any[]): Promise<any>;
493
+ abstract getCookieHeader(args: RequestArgs): string | null | undefined;
494
+ constructor({ apiKey, secretKey, timeout, mitigationServiceUrl, ingestServiceUrl, mitigationType, captchaSiteKey, captchaSecretKey, ingestType, kinesis, mitataCookieExpirySeconds, netaceaCookieExpirySeconds, netaceaCookieName, netaceaCaptchaCookieName }: NetaceaBaseArgs);
495
+ runMitigation(args: RequestArgs): Promise<NetaceaMitigationResponse<Response>>;
496
+ /**
497
+ * Returns the value of the cookie with the given name from a string or list of cookies.
498
+ * If the cookie name is included in the encryptedCookies class property,
499
+ * then the cookie value will be decrypted automatically.
500
+ * The method may operate of either the HTTP Cookie or Set-Cookie headers.
501
+ * @param cookieName the name of the cookie to find.
502
+ * @param cookies the full list of cookies, either as a string or an array of strings.
503
+ * @returns the value of the cookie, if found.
504
+ */
505
+ protected readCookie(cookieName: string, cookies: string | string[] | null | undefined): Promise<string | undefined>;
506
+ protected callIngest(args: IngestArgs): Promise<void>;
507
+ private makeIngestApiCall;
508
+ private constructV1WebLog;
509
+ protected constructWebLog(args: IngestArgs): WebLog;
510
+ protected check(netaceaCookie: string | undefined, clientIP: string, userAgent: string, captchaCookie?: string): Promise<ComposeResultResponse>;
511
+ protected createMitata(clientIP: string, userId: string | undefined, match: string, mitigate: string, captcha: string, maxAge?: number, expiry?: number | undefined): Promise<string>;
512
+ private processCaptcha;
513
+ private getMitataCaptchaFromHeaders;
514
+ private makeCaptchaAPICall;
515
+ private getApiCallResponseFromResponse;
516
+ private buildCookieFromValues;
517
+ private buildCookieHeader;
518
+ private makeMitigateAPICall;
519
+ private composeResult;
520
+ protected findBestMitigation(match: string, mitigate: string, captcha: string, isCaptchaPost: boolean): FindBestMitigationResponse;
521
+ protected APIError(response: APICallResponse): Error;
522
+ protected isUrlCaptchaPost(url: string, method: string): boolean;
523
+ protected processMitigateRequest(args: ProcessMitigateRequestArgs): Promise<ComposeResultResponse>;
524
+ protected setIngestOnlyMitataCookie(userId: string | undefined): Promise<NetaceaResponseBase>;
525
+ protected processIngest(args: RequestArgs): Promise<NetaceaResponseBase>;
526
+ protected encryptCookieValue(cookieValue: string): Promise<string>;
527
+ protected decryptCookieValue(encryptedCookieValue: string): Promise<string>;
528
+ }
529
+ declare class F5 extends NetaceaBase<F5MitigateArgs | F5IngestArgs, F5Response> {
530
+ private readonly httpsAgent;
531
+ private readonly mitataCookieName;
532
+ private readonly mitataCaptchaCookieName;
533
+ constructor(args: F5ConstructorArgs);
534
+ private getInjectHeaders;
535
+ registerMitigateHandler(ilx: IlxServer): void;
536
+ private getValueOrDefault;
537
+ private getArrayValueOrDefault;
538
+ private getMitataCookies;
539
+ private getCookie;
540
+ registerIngestHandler(ilx: IlxServer): void;
541
+ protected makeRequest(args: MakeRequestArgs): Promise<MakeRequestResponse>;
542
+ protected mitigate(args: F5MitigateArgs): Promise<MitigateResponse<F5Response>>;
543
+ protected inject(args: F5MitigateArgs): Promise<InjectResponse>;
544
+ private getMitigationResponse;
545
+ ingest({ ip, userAgent, status, method, path, protocol, referer, bytesSent, requestTime, mitataCookie, sessionStatus }: F5IngestArgs): Promise<any>;
546
+ getCookieHeader(args: F5IngestArgs): string | undefined;
547
+ }
548
+
549
+ export { type F5ConstructorArgs, type IlxServer, F5 as default };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,n,i){return n=a(n),function(t,r){if(r&&("object"==e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,r()?Reflect.construct(n,i||[],a(t).constructor):n.apply(t,i))}function r(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(r=function(){return!!e})()}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}function n(e,t){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n(e,t)}function i(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=g(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var a=0,n=function(){};return{s:n,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw i}}}}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,t,r){return(t=d(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */u=function(){return r};var t,r={},a=Object.prototype,n=a.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",h=o.toStringTag||"@@toStringTag";function p(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(t){p=function(e,t,r){return e[t]=r}}function l(e,t,r,a){var n=t&&t.prototype instanceof k?t:k,o=Object.create(n.prototype),s=new _(a||[]);return i(o,"_invoke",{value:T(e,r,s)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}r.wrap=l;var d="suspendedStart",y="suspendedYield",v="executing",m="completed",g={};function k(){}function b(){}function x(){}var w={};p(w,s,(function(){return this}));var S=Object.getPrototypeOf,C=S&&S(S(j([])));C&&C!==a&&n.call(C,s)&&(w=C);var I=x.prototype=k.prototype=Object.create(w);function A(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function E(t,r){function a(i,o,s,c){var u=f(t[i],t,o);if("throw"!==u.type){var h=u.arg,p=h.value;return p&&"object"==e(p)&&n.call(p,"__await")?r.resolve(p.__await).then((function(e){a("next",e,s,c)}),(function(e){a("throw",e,s,c)})):r.resolve(p).then((function(e){h.value=e,s(h)}),(function(e){return a("throw",e,s,c)}))}c(u.arg)}var o;i(this,"_invoke",{value:function(e,t){function n(){return new r((function(r,n){a(e,t,r,n)}))}return o=o?o.then(n,n):n()}})}function T(e,r,a){var n=d;return function(i,o){if(n===v)throw Error("Generator is already running");if(n===m){if("throw"===i)throw o;return{value:t,done:!0}}for(a.method=i,a.arg=o;;){var s=a.delegate;if(s){var c=O(s,a);if(c){if(c===g)continue;return c}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(n===d)throw n=m,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);n=v;var u=f(e,r,a);if("normal"===u.type){if(n=a.done?m:y,u.arg===g)continue;return{value:u.arg,done:a.done}}"throw"===u.type&&(n=m,a.method="throw",a.arg=u.arg)}}}function O(e,r){var a=r.method,n=e.iterator[a];if(n===t)return r.delegate=null,"throw"===a&&e.iterator.return&&(r.method="return",r.arg=t,O(e,r),"throw"===r.method)||"return"!==a&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+a+"' method")),g;var i=f(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function N(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function j(r){if(r||""===r){var a=r[s];if(a)return a.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var i=-1,o=function e(){for(;++i<r.length;)if(n.call(r,i))return e.value=r[i],e.done=!1,e;return e.value=t,e.done=!0,e};return o.next=o}}throw new TypeError(e(r)+" is not iterable")}return b.prototype=x,i(I,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:b,configurable:!0}),b.displayName=p(x,h,"GeneratorFunction"),r.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,p(e,h,"GeneratorFunction")),e.prototype=Object.create(I),e},r.awrap=function(e){return{__await:e}},A(E.prototype),p(E.prototype,c,(function(){return this})),r.AsyncIterator=E,r.async=function(e,t,a,n,i){void 0===i&&(i=Promise);var o=new E(l(e,t,a,n),i);return r.isGeneratorFunction(t)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},A(I),p(I,h,"Generator"),p(I,s,(function(){return this})),p(I,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var t=Object(e),r=[];for(var a in t)r.push(a);return r.reverse(),function e(){for(;r.length;){var a=r.pop();if(a in t)return e.value=a,e.done=!1,e}return e.done=!0,e}},r.values=j,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(a,n){return s.type="throw",s.arg=e,r.next=a,n&&(r.method="next",r.arg=t),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),N(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var a=r.completion;if("throw"===a.type){var n=a.arg;N(r)}return n}}throw Error("illegal catch attempt")},delegateYield:function(e,r,a){return this.delegate={iterator:j(e),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=t),g}},r}function h(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,d(a.key),a)}}function f(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var a=t[Symbol.toPrimitive];if(void 0!==a){var n=a.call(t,r||"default");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}function y(e,t,r,a,n,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(a,n)}function v(e){return function(){var t=this,r=arguments;return new Promise((function(a,n){var i=e.apply(t,r);function o(e){y(i,a,n,o,s,"next",e)}function s(e){y(i,a,n,o,s,"throw",e)}o(void 0)}))}}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a,n,i,o,s=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(a=i.call(r)).done)&&(s.push(a.value),s.length!==t);c=!0);}catch(e){u=!0,n=e}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw n}}return s}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return k(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(e,t):void 0}}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=Array(t);r<t;r++)a[r]=e[r];return a}var b=require("crypto"),x=require("buffer"),w=require("https"),S=require("aws4");function C(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var I,A,E,T=C(w);!function(e){e.ORIGIN="ORIGIN",e.HTTP="HTTP",e.KINESIS="KINESIS",e.NATIVE="NATIVE"}(I||(I={})),function(e){e.MITIGATE="MITIGATE",e.INJECT="INJECT",e.INGEST="INGEST"}(A||(A={})),function(e){e.CAPTCHA_GET="captcha_get",e.CAPTCHA_POST="captcha_post",e.EXPIRED_SESSION="expired_session",e.FORCED_REVALIDATION="forced_revalidation",e.INVALID_SESSION="invalid_session",e.IP_CHANGE="ip_change",e.NO_SESSION="no_session"}(E||(E={}));var O=3e3;var P="_/@#/",N={none:"",block:"block",captcha:"captcha",allow:"allow",captchaPass:"captchapass"},_={0:N.none,1:N.block,2:N.none,3:N.block,4:N.block},j={1:N.captcha,2:N.captchaPass,3:N.captcha,4:N.allow,5:N.captcha,6:N.captcha,7:N.captcha},K=Object.freeze({__proto__:null,COOKIEDELIMITER:P,bestMitigationCaptchaMap:j,bestMitigationMap:_,captchaMap:{0:"",1:"captcha_serve",2:"captcha_pass",3:"captcha_fail",4:"captcha_cookiepass",5:"captcha_cookiefail",6:"checkpoint_signal",7:"checkpoint_post"},captchaStatusCodes:{"":0,captchaServe:1,captchaPass:2,captchaFail:3,captchaCookiePass:4,captchaCookieFail:5,checkpointSignal:6,checkpointPost:7},matchMap:{0:"",1:"ua_",2:"ip_",3:"visitor_",4:"datacenter_",5:"sev_",6:"organisation_",7:"asn_",8:"country_",9:"combination_",b:"headerFP_"},mitigateMap:{0:"",1:"blocked",2:"allow",3:"hardblocked",4:"block"},mitigationTypes:N,netaceaCookieV3KeyMap:{clientIP:"cip",userId:"uid",gracePeriod:"grp",cookieId:"cid",match:"mat",mitigate:"mit",captcha:"cap",issueTimestamp:"ist",issueReason:"isr"},netaceaCookieV3OptionalKeyMap:{checkAllPostRequests:"fCAPR"},netaceaHeaders:{match:"x-netacea-match",mitigate:"x-netacea-mitigate",captcha:"x-netacea-captcha",mitata:"x-netacea-mitata-value",mitataExpiry:"x-netacea-mitata-expiry",mitataCaptcha:"x-netacea-mitatacaptcha-value",mitataCaptchaExpiry:"x-netacea-mitatacaptcha-expiry",eventId:"x-netacea-event-id"},netaceaSettingsMap:{checkAllPostRequests:"checkAllPostRequests"}}),M="ignored",R="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),L=/^(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/(.*)_\/@#\/((\d|[a-z])(\d)(\d))$/i;function V(e){if(void 0!==e){var t=e.match(L);if(null!=t){var r=m(t,9);return{signature:r[1],expiry:r[2],userId:r[3],ipHash:r[4],mitigationType:r[5],match:r[6],mitigate:r[7],captcha:r[8]}}}}function H(e,t,r,a){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"000";void 0===t&&(t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:R,r=b.randomBytes(e-1),a=Array.from(r).map((function(e){return t[e%t.length]})).join("");return"c".concat(a)}());var i=[r,t,D(e+"|"+String(r),a),n].join(P),o=D(i,a);return"".concat(o).concat(P).concat(i)}function D(e,t){var r=b.createHmac("sha256",t);return r.update(e),x.Buffer.from(r.digest("hex")).toString("base64")}function q(e,t,r){var a={mitata:void 0,requiresReissue:!1,isExpired:!1,shouldExpire:!1,isSameIP:!1,isPrimaryHashValid:!1,captcha:"0",match:"0",mitigate:"0"};if("string"!=typeof e||""===e)return a;var n=V(e);if(void 0!==n){var i=[n.expiry,n.userId,n.ipHash,n.mitigationType].join(P),o=Math.floor(Date.now()/1e3),s=parseInt(n.expiry)<o,c=["1","3","5"].includes(n.captcha),u="3"===n.mitigate,h=c||u,p=D(t+"|"+n.expiry,r),l=n.ipHash===p;return{mitata:n,requiresReissue:s||!l,isExpired:s,shouldExpire:h,isSameIP:l,isPrimaryHashValid:n.signature===D(i,r),match:n.match,mitigate:n.mitigate,captcha:n.captcha,userId:n.userId}}return a}var G={},B={},U={},F={};Object.defineProperty(F,"__esModule",{value:!0}),F.API_VERSION=F.REGION=F.PAYLOAD_TYPE=F.STATE=void 0,F.STATE={ACTIVE:"ACTIVE",UPDATING:"UPDATING",CREATING:"CREATING",DELETING:"DELETING"},F.PAYLOAD_TYPE="string",F.REGION="eu-west-1",F.API_VERSION="2013-12-02",Object.defineProperty(U,"__esModule",{value:!0}),U.signRequest=void 0;var z=S,X=F;function J(e,t){for(var r=[],a=0;a<e.length;a+=t){var n=e.slice(a,a+t);r.push({Data:Buffer.from(JSON.stringify(n)).toString("base64"),PartitionKey:Date.now().toString()})}return r}U.signRequest=function(e,t,r){var a=e.accessKeyId,n=e.secretAccessKey,i={Records:J(t,r),PartitionKey:Date.now().toString(),StreamName:e.streamName};return z.sign({service:"kinesis",body:JSON.stringify(i),headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"Kinesis_20131202.PutRecords"},region:X.REGION},{accessKeyId:a,secretAccessKey:n})},Object.defineProperty(B,"__esModule",{value:!0});var W=U;function Y(e){return $.apply(this,arguments)}function $(){return($=v(u().mark((function e(t){return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise((function(e){setTimeout(e,t)}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Q=function(){return f((function e(t){var r=t.kinesisStreamName,a=t.kinesisAccessKey,n=t.kinesisSecretKey,i=t.maxLogAgeSeconds,o=t.logBatchSize,s=t.rampUpBatchSize,c=t.maxAwaitTimePerIngestCallMs;p(this,e),this.maxLogBatchSize=20,this.maxLogAgeSeconds=10,this.logBatchSize=20,this.logCache=[],this.intervalSet=!1,this.kinesisStreamName=r,this.kinesisAccessKey=a,this.kinesisSecretKey=n,this.maxAwaitTimePerIngestCallMs=c,void 0!==i&&i<this.maxLogAgeSeconds&&i>0&&(this.maxLogAgeSeconds=i),void 0!==o&&(this.maxLogBatchSize=o),this.logBatchSize=!0===s?1:this.maxLogBatchSize}),[{key:"putToKinesis",value:(t=v(u().mark((function e(t){var r,a,n,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.logCache.length){e.next=1;break}return e.abrupt("return");case 1:return r=h(this.logCache),this.logCache=[],e.prev=2,a=(0,W.signRequest)({streamName:this.kinesisStreamName,accessKeyId:this.kinesisAccessKey,secretAccessKey:this.kinesisSecretKey},r,this.logBatchSize),e.next=3,t({headers:a.headers,host:"https://".concat(a.hostname),method:a.method,path:a.path,body:a.body});case 3:this.logBatchSize!==this.maxLogBatchSize&&(this.logBatchSize=Math.min(this.maxLogBatchSize,2*this.logBatchSize)),e.next=5;break;case 4:e.prev=4,i=e.catch(2),(n=this.logCache).push.apply(n,h(r)),console.error(i);case 5:case"end":return e.stop()}}),e,this,[[2,4]])}))),function(e){return t.apply(this,arguments)})},{key:"ingest",value:(e=v(u().mark((function e(t,r){var a,n,i=this;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.logCache.push(t),!(this.logCache.length>=this.logBatchSize)){e.next=2;break}return(a=[]).push(this.putToKinesis(r)),void 0!==this.maxAwaitTimePerIngestCallMs&&a.push(Y(this.maxAwaitTimePerIngestCallMs)),e.next=1,Promise.race(a);case 1:e.next=3;break;case 2:if(this.intervalSet){e.next=3;break}if(this.intervalSet=!0,n=Y(1e3*this.maxLogAgeSeconds).then(v(u().mark((function e(){return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,i.putToKinesis(r);case 1:i.intervalSet=!1;case 2:case"end":return e.stop()}}),e)})))).catch((function(){})),void 0!==this.maxAwaitTimePerIngestCallMs){e.next=3;break}return e.next=3,n;case 3:case"end":return e.stop()}}),e,this)}))),function(t,r){return e.apply(this,arguments)})}]);var e,t}();B.default=Q,Object.defineProperty(G,"__esModule",{value:!0});var Z=B,ee=G.default=Z.default,te=function(){return f((function e(t){var r=t.apiKey,a=t.secretKey,n=t.timeout,i=void 0===n?3e3:n,o=t.mitigationServiceUrl,u=void 0===o?"https://mitigations.netacea.net":o,h=t.ingestServiceUrl,l=void 0===h?"https://ingest.netacea.net":h,f=t.mitigationType,d=void 0===f?A.INGEST:f,y=t.captchaSiteKey,v=t.captchaSecretKey,m=t.ingestType,g=void 0===m?I.HTTP:m,k=t.kinesis,b=t.mitataCookieExpirySeconds,x=t.netaceaCookieExpirySeconds,w=t.netaceaCookieName,S=t.netaceaCaptchaCookieName;if(p(this,e),c(this,"mitataCookieExpirySeconds",void 0),c(this,"apiKey",void 0),c(this,"secretKey",void 0),c(this,"mitigationServiceUrl",void 0),c(this,"ingestServiceUrl",void 0),c(this,"timeout",void 0),c(this,"captchaSiteKey",void 0),c(this,"captchaSecretKey",void 0),c(this,"ingestType",void 0),c(this,"kinesis",void 0),c(this,"mitigationType",void 0),c(this,"encryptedCookies",[]),c(this,"netaceaCookieName",void 0),c(this,"netaceaCaptchaCookieName",void 0),null==r)throw new Error("apiKey is a required parameter");this.apiKey=r,this.secretKey=a,this.mitigationServiceUrl=u,this.ingestServiceUrl=l,this.mitigationType=d,this.ingestType=null!=g?g:I.HTTP,this.ingestType===I.KINESIS&&(void 0===k?console.warn("NETACEA WARN: no kinesis args provided, when ingestType is ".concat(this.ingestType)):this.kinesis=new ee(s(s({},k),{},{apiKey:this.apiKey}))),void 0===y&&void 0===v||(this.captchaSiteKey=y,this.captchaSecretKey=v),this.timeout=function(e){return e<=0?O:e}(i),this.netaceaCookieName=null!=w?w:"_mitata",this.netaceaCaptchaCookieName=null!=S?S:"_mitatacaptcha",this.encryptedCookies=[this.netaceaCookieName,this.netaceaCaptchaCookieName],this.mitataCookieExpirySeconds=function(e,t){return void 0===t?e===A.INGEST?3600:60:t}(d,null!=x?x:b)}),[{key:"runMitigation",value:(S=v(u().mark((function e(t){var r,a,n,i,o;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,i=this.mitigationType,e.next=i===A.MITIGATE?1:i===A.INJECT?3:i===A.INGEST?5:7;break;case 1:return e.next=2,this.mitigate(t);case 2:case 4:case 6:return e.abrupt("return",e.sent);case 3:return e.next=4,this.inject(t);case 5:return e.next=6,this.processIngest(t);case 7:throw new Error("Netacea Error: Mitigation type ".concat(this.mitigationType," not recognised"));case 8:e.next=10;break;case 9:return e.prev=9,o=e.catch(0),console.error("Netacea FAILOPEN Error:",o),r=t,a=this.isUrlCaptchaPost(r.url,r.method),n=this.mitigationType===A.MITIGATE,e.abrupt("return",{injectHeaders:{"x-netacea-captcha":"0","x-netacea-match":"0","x-netacea-mitigate":"0"},sessionStatus:n&&a?"error_open":""});case 10:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(e){return S.apply(this,arguments)})},{key:"readCookie",value:(w=v(u().mark((function e(t,r){var a,n,o,s,c,h,p;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=r){e.next=1;break}return e.abrupt("return",void 0);case 1:if("string"!=typeof r){e.next=3;break}return e.next=2,this.readCookie(t,r.split(";"));case 2:return e.abrupt("return",e.sent);case 3:a="".concat(t,"="),n=i(r),e.prev=4,n.s();case 5:if((o=n.n()).done){e.next=11;break}if(s=o.value,!(c=s.split(";")[0].trimStart()).startsWith(a)){e.next=10;break}if(h=c.slice(a.length),!this.encryptedCookies.includes(t)){e.next=9;break}return e.prev=6,e.next=7,this.decryptCookieValue(h);case 7:return e.abrupt("return",e.sent);case 8:return e.prev=8,e.catch(6),e.abrupt("return",void 0);case 9:return e.abrupt("return",h);case 10:e.next=5;break;case 11:e.next=13;break;case 12:e.prev=12,p=e.catch(4),n.e(p);case 13:return e.prev=13,n.f(),e.finish(13);case 14:return e.abrupt("return",void 0);case 15:case"end":return e.stop()}}),e,this,[[4,12,13,14],[6,8]])}))),function(e,t){return w.apply(this,arguments)})},{key:"callIngest",value:(x=v(u().mark((function e(t){var r,a,n,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.constructWebLog(t),this.ingestType!==I.KINESIS){e.next=5;break}if(void 0!==this.kinesis){e.next=1;break}return console.error("Netacea Error: Unable to log as Kinesis has not been defined."),e.abrupt("return");case 1:return e.prev=1,e.next=2,this.kinesis.ingest(s(s({},r),{},{apiKey:this.apiKey}),this.makeRequest.bind(this));case 2:e.next=4;break;case 3:e.prev=3,i=e.catch(1),console.error("NETACEA Error: ",i.message);case 4:e.next=7;break;case 5:return a={"X-Netacea-API-Key":this.apiKey,"content-type":"application/json"},e.next=6,this.makeIngestApiCall(a,r);case 6:if(200===(n=e.sent).status){e.next=7;break}throw this.APIError(n);case 7:case"end":return e.stop()}}),e,this,[[1,3]])}))),function(e){return x.apply(this,arguments)})},{key:"makeIngestApiCall",value:(b=v(u().mark((function e(t,r){return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.makeRequest({host:this.ingestServiceUrl,method:"POST",path:"/",headers:t,body:JSON.stringify(r),timeout:this.timeout});case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"constructV1WebLog",value:function(e){var t=e.ip,r=e.userAgent,a=e.status,n=e.method,i=e.path,o=e.protocol,s=e.referer,c=e.bytesSent,u=e.requestTime,h=e.mitataCookie,p=e.sessionStatus,l=e.integrationType,f=e.integrationVersion,d=(new Date).toUTCString();return{Request:"".concat(n," ").concat(i," ").concat(o),TimeLocal:d,RealIp:t,UserAgent:r,Status:a,RequestTime:null==u?void 0:u.toString(),BytesSent:null==c?void 0:c.toString(),Referer:""===s?"-":s,NetaceaUserIdCookie:null!=h?h:"",NetaceaMitigationApplied:null!=p?p:"",IntegrationType:null!=l?l:"",IntegrationVersion:null!=f?f:""}}},{key:"constructWebLog",value:function(e){return e.bytesSent=""===e.bytesSent?"0":e.bytesSent,this.constructV1WebLog(e)}},{key:"check",value:(k=v(u().mark((function e(t,r,a,n){var i,o,s,c,h,p,l,f,d,y,v,m;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this.secretKey){e.next=1;break}throw new Error("Secret key is required to mitigate");case 1:if((f=q(t,r,this.secretKey)).isPrimaryHashValid&&!f.requiresReissue){e.next=4;break}return e.next=2,this.makeMitigateAPICall(null===(d=f.mitata)||void 0===d?void 0:d.userId,r,a,n);case 2:return v=e.sent,i=v.status,o=v.match,s=v.mitigate,c=v.captcha,h=v.body,e.next=3,this.createMitata(r,null===(y=f.mitata)||void 0===y?void 0:y.userId,o,s,c,v.mitataMaxAge);case 3:m=e.sent,p=[m],l=v.eventId,e.next=5;break;case 4:i=-1,o=f.match,s=f.mitigate,c=f.captcha,h=void 0,p=[];case 5:return e.abrupt("return",this.composeResult(h,p,i,o,s,c,!1,l));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a){return k.apply(this,arguments)})},{key:"createMitata",value:(g=v(u().mark((function e(t,r,a,n,i){var o,s,c,h,p,l,f,d,y=arguments;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=y.length>5&&void 0!==y[5]?y[5]:86400,s=y.length>6&&void 0!==y[6]?y[6]:void 0,c=["1","3","5"].includes(i),h="3"===n,p=c||h?-60:this.mitataCookieExpirySeconds,l=null!=s?s:Math.floor(Date.now()/1e3)+p,void 0!==this.secretKey){e.next=1;break}throw new Error("Cannot build cookie without secret key.");case 1:return f=[a,n,i].join(""),d=H(t,r,l,this.secretKey,f),e.next=2,this.buildCookieFromValues(this.netaceaCookieName,d,o,"/");case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a,n){return g.apply(this,arguments)})},{key:"processCaptcha",value:(m=v(u().mark((function e(t,r,a,n){var i,o,s,c,h,p,l;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.makeCaptchaAPICall(t,r,a,n);case 1:return i=e.sent,o=i.status,s=i.match,c=i.mitigate,h=i.captcha,p=i.body,l=i.setCookie,e.abrupt("return",this.composeResult(p,l,o,s,c,h,!0));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a){return m.apply(this,arguments)})},{key:"getMitataCaptchaFromHeaders",value:(y=v(u().mark((function e(t){var r,a,n;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Object.prototype.hasOwnProperty.call(t,K.netaceaHeaders.mitataCaptcha)){e.next=2;break}return r=t[K.netaceaHeaders.mitataCaptcha],a=parseInt(t[K.netaceaHeaders.mitataCaptchaExpiry]),e.next=1,this.buildCookieFromValues(this.netaceaCaptchaCookieName,r,a);case 1:if(void 0===(n=e.sent)){e.next=2;break}return e.abrupt("return",n);case 2:return e.abrupt("return",void 0);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"makeCaptchaAPICall",value:(d=v(u().mark((function e(t,r,a,n){var i,o,s;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":a,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},void 0!==(o=V(t))&&(i["X-Netacea-UserId"]=o.userId),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(i["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,i["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/AtaVerifyCaptcha",headers:i,method:"POST",body:n,timeout:this.timeout});case 1:return s=e.sent,e.next=2,this.getApiCallResponseFromResponse(s,null==o?void 0:o.userId,r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a){return d.apply(this,arguments)})},{key:"getApiCallResponseFromResponse",value:(l=v(u().mark((function e(t,r,a){var n,i,o,s,c,h,p,l,f,d,y,v,m,g;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(200===t.status){e.next=1;break}throw this.APIError(t);case 1:return p=null!==(n=null===(i=t.headers[K.netaceaHeaders.match])||void 0===i?void 0:i.toString())&&void 0!==n?n:"0",l=null!==(o=null===(s=t.headers[K.netaceaHeaders.mitigate])||void 0===s?void 0:s.toString())&&void 0!==o?o:"0",f=null!==(c=null===(h=t.headers[K.netaceaHeaders.captcha])||void 0===h?void 0:h.toString())&&void 0!==c?c:"0",d=parseInt(t.headers[K.netaceaHeaders.mitataExpiry]),isNaN(d)&&(d=86400),e.next=2,this.createMitata(a,r,p,l,f);case 2:return y=e.sent,e.next=3,this.getMitataCaptchaFromHeaders(t.headers);case 3:return v=e.sent,m=[y,v].filter((function(e){return void 0!==e})),g=t.headers[K.netaceaHeaders.eventId],e.abrupt("return",{status:t.status,match:p,mitigate:l,captcha:f,setCookie:m,body:t.body,eventId:g,mitataMaxAge:d});case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return l.apply(this,arguments)})},{key:"buildCookieFromValues",value:(h=v(u().mark((function e(t,r,a){var n,i,o=arguments;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>3&&void 0!==o[3]?o[3]:"/",!this.encryptedCookies.includes(t)){e.next=2;break}return e.next=1,this.encryptCookieValue(r);case 1:return i=e.sent,e.abrupt("return","".concat(t,"=").concat(i,"; Max-Age=").concat(a,"; Path=").concat(n));case 2:return e.abrupt("return","".concat(t,"=").concat(r,"; Max-Age=").concat(a,"; Path=").concat(n));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return h.apply(this,arguments)})},{key:"buildCookieHeader",value:function(e){var t="",r="";for(var a in e){var n=e[a];void 0!==n&&(t="".concat(t).concat(r).concat(a,"=").concat(n),r="; ")}return t}},{key:"makeMitigateAPICall",value:(o=v(u().mark((function e(t,r,a,n){var i,o;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={"X-Netacea-API-Key":this.apiKey,"X-Netacea-Client-IP":r,"user-agent":a,cookie:this.buildCookieHeader({_mitatacaptcha:n})},void 0!==t&&(i["X-Netacea-UserId"]=t),void 0!==this.captchaSiteKey&&void 0!==this.captchaSecretKey&&(i["X-Netacea-Captcha-Site-Key"]=this.captchaSiteKey,i["X-Netacea-Captcha-Secret-Key"]=this.captchaSecretKey),e.next=1,this.makeRequest({host:this.mitigationServiceUrl,path:"/",headers:i,method:"GET",timeout:this.timeout});case 1:return o=e.sent,e.next=2,this.getApiCallResponseFromResponse(o,t,r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,a){return o.apply(this,arguments)})},{key:"composeResult",value:function(e,t,r,a,n,i,o,s){var c=this.findBestMitigation(a,n,i,o),u={body:e,apiCallStatus:r,setCookie:t,sessionStatus:c.sessionStatus,mitigation:c.mitigation,mitigated:[K.mitigationTypes.block,K.mitigationTypes.captcha,K.mitigationTypes.captchaPass].includes(c.mitigation)};if(this.mitigationType===A.INJECT){var h={"x-netacea-match":c.parts.match.toString(),"x-netacea-mitigate":c.parts.mitigate.toString(),"x-netacea-captcha":c.parts.captcha.toString()};void 0!==s&&(h["x-netacea-event-id"]=s),u.injectHeaders=h}return u}},{key:"findBestMitigation",value:function(e,t,r,a){var n,i,o="unknown";a||("2"===r?r="4":"3"===r&&(r="5"));var s=null!==(n=K.matchMap[e])&&void 0!==n?n:o+"_";s+=null!==(i=K.mitigateMap[t])&&void 0!==i?i:o;var c=K.bestMitigationMap[t];if("0"!==r){var u;s+=","+(null!==(u=K.captchaMap[r])&&void 0!==u?u:o);var h=K.bestMitigationCaptchaMap[r];void 0!==h&&(c=h)}return this.mitigationType===A.INJECT&&(c=K.mitigationTypes.none),{sessionStatus:s,mitigation:c,parts:{match:e,mitigate:t,captcha:r}}}},{key:"APIError",value:function(e){var t="Unknown error";switch(e.status){case 403:t="Invalid credentials";break;case 500:t="Server error";break;case 502:t="Bad Gateway";break;case 503:t="Service Unavailable";break;case 400:t="Invalid request"}return new Error("Error reaching Netacea API (".concat(t,"), status: ").concat(e.status))}},{key:"isUrlCaptchaPost",value:function(e,t){return e.includes("/AtaVerifyCaptcha")&&"post"===t.toLowerCase()}},{key:"processMitigateRequest",value:(n=v(u().mark((function e(t){var r,a,n,i,o,s;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isUrlCaptchaPost(t.url,t.method)){e.next=2;break}return a=this,n=t.mitata,i=t.clientIp,o=t.userAgent,e.next=1,t.getBodyFn();case 1:s=e.sent,r=a.processCaptcha.call(a,n,i,o,s),e.next=3;break;case 2:r=this.check(t.mitata,t.clientIp,t.userAgent,t.mitataCaptcha);case 3:return e.next=4,r;case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setIngestOnlyMitataCookie",value:(a=v(u().mark((function e(t){var r;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.createMitata(M,t,"0","0","0",86400);case 1:return r=e.sent,e.abrupt("return",{sessionStatus:"",setCookie:[r]});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"processIngest",value:(r=v(u().mark((function e(t){var r,a,n,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==this.secretKey){e.next=1;break}throw new Error("Secret key is required for ingest");case 1:return r=this.getCookieHeader(t),e.next=2,this.readCookie(this.netaceaCookieName,r);case 2:if(a=e.sent,(n=q(a,M,this.secretKey)).isPrimaryHashValid){e.next=4;break}return e.next=3,this.setIngestOnlyMitataCookie(void 0);case 3:case 5:return e.abrupt("return",e.sent);case 4:if(!n.requiresReissue){e.next=6;break}return e.next=5,this.setIngestOnlyMitataCookie(null===(i=n.mitata)||void 0===i?void 0:i.userId);case 6:return e.abrupt("return",{sessionStatus:"",setCookie:[]});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"encryptCookieValue",value:(t=v(u().mark((function e(t){return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"decryptCookieValue",value:(e=v(u().mark((function e(t){return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,r,a,n,o,h,l,d,y,m,g,k,b,x,w,S}(),re=function(){function e(r){var a,n,i,o;return p(this,e),c(o=t(this,e,[r]),"httpsAgent",void 0),c(o,"mitataCookieName",void 0),c(o,"mitataCaptchaCookieName",void 0),o.httpsAgent=new T.Agent({timeout:o.timeout,keepAlive:!0,maxSockets:null!==(a=r.maxSockets)&&void 0!==a?a:25}),o.mitataCookieName=null!==(n=r.netaceaCookieName)&&void 0!==n?n:"_mitata",o.mitataCaptchaCookieName=null!==(i=r.netaceaCaptchaCookieName)&&void 0!==i?i:"_mitatacaptcha",o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&n(e,t)}(e,te),f(e,[{key:"getInjectHeaders",value:function(e){if(this.mitigationType===A.INJECT){var t,r,a,n,i=e;if(void 0!==i.injectHeaders)return[null!==(t=i.injectHeaders["x-netacea-match"])&&void 0!==t?t:"0",null!==(r=i.injectHeaders["x-netacea-mitigate"])&&void 0!==r?r:"0",null!==(a=i.injectHeaders["x-netacea-captcha"])&&void 0!==a?a:"0",null!==(n=i.injectHeaders["x-netacea-event-id"])&&void 0!==n?n:""]}return[]}},{key:"registerMitigateHandler",value:function(e){var t=this;e.addMethod("handleRequest",function(){var e=v(u().mark((function e(r,a){var n,i,o,s,c,h,p,l,f,d,y,v,g,k,b,x,w,S,C;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.params(),i=m(n,5),o=i[0],s=i[1],c=i[2],h=i[3],p=i[4],l=6===n.length?t.getArrayValueOrDefault(n,5,void 0):void 0,e.prev=1,f=t.getMitataCookies(p),d=m(f,2),y=d[0],v=d[1],e.next=2,t.runMitigation({ip:o,method:c,url:h,mitataCaptchaCookie:v,mitataCookie:y,userAgent:s,body:l});case 2:if("error_open"!==(null==(g=e.sent)?void 0:g.sessionStatus)){e.next=3;break}return a.reply(["",500,[],"error_open",!0,"",[]]),e.abrupt("return");case 3:if(void 0!==g){e.next=4;break}return a.reply(["",0,[],"",!1,"",[]]),e.abrupt("return");case 4:k="",b=0,x=!1,w=t.getValueOrDefault(y,""),void 0!==g.setCookie&&g.setCookie.length>0&&void 0!==(S=g.setCookie.find((function(e){return e.includes("".concat(t.netaceaCookieName,"="))})))&&(w=S.split(";")[0].replace("".concat(t.netaceaCookieName,"="),"")),void 0!==g.response&&(b=g.response.apiCallStatus,k=t.getValueOrDefault(g.response.body,"Forbidden"),x=t.getValueOrDefault(g.response.mitigated,x)),a.reply([k,b,t.getValueOrDefault(g.setCookie,[]),g.sessionStatus,x,t.getValueOrDefault(w,""),t.getInjectHeaders(g)]),e.next=6;break;case 5:e.prev=5,C=e.catch(1),console.error("Could not reach Netacea mitigation API: ",C.message),a.reply(["",0,[],"",!1,"",[]]);case 6:case"end":return e.stop()}}),e,null,[[1,5]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"getValueOrDefault",value:function(e,t){return null!=e?e:t}},{key:"getArrayValueOrDefault",value:function(e,t,r){var a;return null!==(a=e[t])&&void 0!==a?a:r}},{key:"getMitataCookies",value:function(e){var t=null==e?void 0:e.split("; ");return[this.getCookie(this.mitataCookieName,t),this.getCookie(this.mitataCaptchaCookieName,t)]}},{key:"getCookie",value:function(e,t){var r;return null==t||null===(r=t.find((function(t){return t.includes("".concat(e,"="))})))||void 0===r?void 0:r.replace("".concat(e,"="),"")}},{key:"registerIngestHandler",value:function(e){var t=this;e.addMethod("ingest",(function(e,r){var a=e.params(),n=t.getArrayValueOrDefault(a,0,""),i=t.getArrayValueOrDefault(a,1,""),o=t.getArrayValueOrDefault(a,2,"-1"),s=t.getArrayValueOrDefault(a,3,""),c=t.getArrayValueOrDefault(a,4,""),u=t.getArrayValueOrDefault(a,5,""),h=t.getArrayValueOrDefault(a,6,""),p=t.getArrayValueOrDefault(a,7,"0"),l=t.getArrayValueOrDefault(a,8,"0"),f=t.getArrayValueOrDefault(a,9,""),d=t.getArrayValueOrDefault(a,10,"");t.ingest({ip:n,userAgent:i,status:o,method:s,path:c,protocol:u,referer:h,bytesSent:p,requestTime:l,mitataCookie:f,sessionStatus:d}).catch((function(e){console.error("Could not reach Netacea ingest API: "+e.message)})),r.reply("done")}))}},{key:"makeRequest",value:(s=v(u().mark((function e(t){var r=this;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise((function(e,a){t.host=t.host.replace("https://","");for(var n=T.request({agent:r.httpsAgent,host:t.host,path:t.path,headers:t.headers,method:t.method,body:t.body},(function(t){var r="";t.on("data",(function(e){r+=e})),t.on("end",(function(){var a;e({headers:t.headers,status:null!==(a=t.statusCode)&&void 0!==a?a:0,body:""===r?void 0:r})}))})),i=0,o=["error","abort","timeout"];i<o.length;i++){var s=o[i];n.on(s,(function(e){a(e),n.destroyed||n.destroy()}))}"post"===t.method.toLowerCase()&&n.write(t.body),n.end()}));case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e)}))),function(e){return s.apply(this,arguments)})},{key:"mitigate",value:(o=v(u().mark((function e(t){var r,a,n,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getMitigationResponse(t);case 1:return r=e.sent,a={sessionStatus:r.sessionStatus,setCookie:r.setCookie},r.mitigated&&(a.response={body:null!==(n=r.body)&&void 0!==n?n:"Forbidden",status:403,apiCallStatus:null!==(i=r.apiCallStatus)&&void 0!==i?i:-1,mitigation:r.mitigation,mitigated:r.mitigated}),e.abrupt("return",a);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"inject",value:(i=v(u().mark((function e(t){var r;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getMitigationResponse(t);case 1:return r=e.sent,e.abrupt("return",{injectHeaders:r.injectHeaders,sessionStatus:r.sessionStatus,setCookie:r.setCookie});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getMitigationResponse",value:(a=v(u().mark((function e(t){var r,a,n,i,o,s,c;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ip,a=t.userAgent,n=t.url,i=t.method,o=t.mitataCookie,s=t.mitataCaptchaCookie,c=t.body,e.next=1,this.processMitigateRequest({clientIp:r,getBodyFn:function(){var e=v(u().mark((function e(){return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,Promise.resolve(c);case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),method:i,mitata:o,mitataCaptcha:s,url:n,userAgent:a});case 1:return e.abrupt("return",e.sent);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"ingest",value:(r=v(u().mark((function e(t){var r,a,n,i,o,s,c,h,p,l,f;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ip,a=t.userAgent,n=t.status,i=t.method,o=t.path,s=t.protocol,c=t.referer,h=t.bytesSent,p=t.requestTime,l=t.mitataCookie,f=t.sessionStatus,e.next=1,this.callIngest({ip:r,userAgent:a,status:n,method:i,bytesSent:h,path:o,protocol:s,referer:c,requestTime:p,mitataCookie:l,sessionStatus:f,integrationType:"@netacea/f5".replace("@netacea/",""),integrationVersion:"4.3.124"});case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getCookieHeader",value:function(e){if(void 0!==e.mitataCookie)return"".concat(this.mitataCookieName,"=").concat(e.mitataCookie)}}]);var r,a,i,o,s}();module.exports=re;
2
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@netacea/f5",
3
- "version": "4.3.123",
3
+ "version": "4.3.124",
4
4
  "description": "Netacea F5 CDN integration",
5
- "main": "dist/src/index.js",
6
- "types": "dist/src/index.d.ts",
5
+ "files": [
6
+ "dist/index.js",
7
+ "dist/index.d.ts"
8
+ ],
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
7
11
  "scripts": {
8
12
  "prepack": "npx netacea-bundler prepack",
9
13
  "postpack": "npx netacea-bundler postpack"
@@ -14,9 +18,8 @@
14
18
  },
15
19
  "license": "ISC",
16
20
  "dependencies": {
17
- "@netacea/kinesisingest": "^1.5.123",
18
- "@netacea/netaceaintegrationbase": "^2.0.105",
21
+ "aws4": "^1.13.2",
19
22
  "f5-nodejs": "^1.0.0"
20
23
  },
21
- "gitHead": "ee962ea3a9dee8836026379542151557dc6541dd"
24
+ "gitHead": "13b188cdfc04aa2ad3d79e50990589974c2c8556"
22
25
  }