@netacea/akamai 5.0.80 → 5.0.82

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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 5.0.82 (2024-02-09)
7
+
8
+ **Note:** Version bump only for package @netacea/akamai
9
+
10
+
11
+
12
+
13
+
14
+ ## 5.0.81 (2024-02-06)
15
+
16
+ **Note:** Version bump only for package @netacea/akamai
17
+
18
+
19
+
20
+
21
+
6
22
  ## 5.0.80 (2024-02-05)
7
23
 
8
24
  **Note:** Version bump only for package @netacea/akamai
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netacea/akamai",
3
- "version": "5.0.80",
3
+ "version": "5.0.82",
4
4
  "description": "Netacea Akamai CDN Integration",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "license": "ISC",
22
22
  "dependencies": {
23
- "@netacea/netaceaintegrationbase": "^1.16.86",
23
+ "@netacea/netaceaintegrationbase": "^1.16.88",
24
24
  "buffer": "^6.0.3",
25
25
  "jssha": "^3.3.0"
26
26
  },
@@ -67,5 +67,5 @@
67
67
  "tslib": "^2.0.3",
68
68
  "typescript": "^4.0.3"
69
69
  },
70
- "gitHead": "0dd37124b1512d13ebf936f35831cab3c23796ef"
70
+ "gitHead": "55adcd2ab41834da89f216e570ad4acd3788d601"
71
71
  }
@@ -0,0 +1,13 @@
1
+ import type { FindBestMitigationResponse } from '@netacea/netaceaintegrationbase';
2
+ import type { AkamaiRuntimeDependencies, AkamaiWorkerConfig } from '../types';
3
+ export interface BestActionResponse {
4
+ body?: string;
5
+ apiCallStatus: number;
6
+ setCookie: string[];
7
+ sessionStatus: string;
8
+ mitigation: string;
9
+ mitigated: boolean;
10
+ bestMitigation: FindBestMitigationResponse;
11
+ eventId: string | undefined;
12
+ }
13
+ export declare function getBestActionFromMitigationAPI(deps: AkamaiRuntimeDependencies, config: Readonly<AkamaiWorkerConfig>, netaceaCookie: string | undefined, clientIP: string, userAgent: string, accept: string, host: string, captchaCookie?: string): Promise<BestActionResponse>;
@@ -0,0 +1,47 @@
1
+ import { retrieveCookieInfo } from './retrieveCookieInfo';
2
+ import { createProtoMitata } from './createProtoMitata';
3
+ import { makeMitigateApiCall } from '../mitigation/makeMitigateApiCall';
4
+ import { findBestMitigation } from './findBestMitigation';
5
+ import { dictionary } from '@netacea/netaceaintegrationbase';
6
+ const { mitigationTypes } = dictionary;
7
+ const BLOCKING_MITIGATION_TYPES = [
8
+ mitigationTypes.block,
9
+ mitigationTypes.captcha,
10
+ mitigationTypes.captchaPass
11
+ ];
12
+ function getDefaultIntegrationResponse(cookieInfo) {
13
+ return {
14
+ status: -1,
15
+ match: cookieInfo.match,
16
+ mitigate: cookieInfo.mitigate,
17
+ captcha: cookieInfo.captcha,
18
+ mitataMaxAge: 86400,
19
+ setCookie: []
20
+ };
21
+ }
22
+ export async function getBestActionFromMitigationAPI(deps, config, netaceaCookie, clientIP, userAgent, accept, host, captchaCookie) {
23
+ const cookieInfo = await retrieveCookieInfo(netaceaCookie, clientIP, config.secretKey);
24
+ let integrationResponse = getDefaultIntegrationResponse(cookieInfo);
25
+ if (config.secretKey === undefined) {
26
+ throw new Error('Secret key is required to mitigate');
27
+ }
28
+ if (!cookieInfo.isPrimaryHashValid || cookieInfo.requiresReissue) {
29
+ integrationResponse = await makeMitigateApiCall(deps, config, cookieInfo.mitata?.userId, clientIP, userAgent, captchaCookie, accept, host);
30
+ integrationResponse.setCookie = [
31
+ await createProtoMitata(clientIP, cookieInfo.mitata?.userId, integrationResponse.match, integrationResponse.mitigate, integrationResponse.captcha, integrationResponse.mitataMaxAge)
32
+ ];
33
+ }
34
+ const bestMitigation = findBestMitigation(config, integrationResponse.match, integrationResponse.mitigate, integrationResponse.captcha, false);
35
+ const result = {
36
+ body: integrationResponse.body,
37
+ apiCallStatus: integrationResponse.status,
38
+ setCookie: integrationResponse.setCookie,
39
+ sessionStatus: bestMitigation.sessionStatus,
40
+ mitigation: bestMitigation.mitigation,
41
+ mitigated: BLOCKING_MITIGATION_TYPES.includes(bestMitigation.mitigation),
42
+ bestMitigation,
43
+ eventId: integrationResponse.eventId
44
+ };
45
+ return result;
46
+ }
47
+ //# sourceMappingURL=getBestActionFromMitigationAPI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBestActionFromMitigationAPI.js","sourceRoot":"","sources":["../../../src/helpers/getBestActionFromMitigationAPI.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAC5D,MAAM,EAAE,eAAe,EAAE,GAAG,UAAU,CAAA;AAEtC,MAAM,yBAAyB,GAAG;IAChC,eAAe,CAAC,KAAK;IACrB,eAAe,CAAC,OAAO;IACvB,eAAe,CAAC,WAAW;CAC5B,CAAA;AAiCD,SAAS,6BAA6B,CAAE,UAA+B;IACrE,OAAO;QACL,MAAM,EAAE,CAAC,CAAC;QACV,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,YAAY,EAAE,KAAK;QACnB,SAAS,EAAE,EAAE;KACd,CAAA;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,IAA+B,EAC/B,MAAoC,EACpC,aAAiC,EACjC,QAAgB,EAChB,SAAiB,EACjB,MAAc,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AO;KACrC,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,4 +1,4 @@
1
1
  /// <reference types="akamai-edgeworkers" />
2
- import type { ComposeResultResponse } from '@netacea/netaceaintegrationbase';
3
2
  import type { AkamaiRuntimeDependencies, AkamaiWorkerConfig } from '../types';
4
- export declare function getMitigationResponse(deps: AkamaiRuntimeDependencies, config: Readonly<AkamaiWorkerConfig>, request: EW.IngressClientRequest): Promise<ComposeResultResponse>;
3
+ import { BestActionResponse } from './getBestActionFromMitigationAPI';
4
+ export declare function getMitigationResponse(deps: AkamaiRuntimeDependencies, config: Readonly<AkamaiWorkerConfig>, request: EW.IngressClientRequest): Promise<BestActionResponse>;
@@ -1,24 +1,14 @@
1
1
  import { getHeaderValueOrDefault } from './getHeaderValueOrDefault';
2
2
  import { readCookie } from './readCookie';
3
3
  import { getVariableOrDefault } from './getVariable';
4
- import { processMitigateRequest } from './processMitigateRequest';
4
+ import { getBestActionFromMitigationAPI } from './getBestActionFromMitigationAPI';
5
5
  export async function getMitigationResponse(deps, config, request) {
6
6
  const cookies = getHeaderValueOrDefault(request, 'cookie');
7
7
  const netaceaCookie = await readCookie(deps, config, cookies, config.netaceaCookieName);
8
8
  const mitataCaptcha = await readCookie(deps, config, cookies, config.netaceaCaptchaCookieName);
9
9
  const clientIp = getVariableOrDefault(request, 'PMUSER_CLIENT_IP');
10
10
  const userAgent = getHeaderValueOrDefault(request, 'user-agent');
11
- const accept = getHeaderValueOrDefault(request, 'accept', 'text/html');
12
- return await processMitigateRequest(deps, config, {
13
- clientIp,
14
- getBodyFn: async () => '',
15
- method: request.method,
16
- mitata: netaceaCookie,
17
- mitataCaptcha,
18
- url: request.path,
19
- userAgent,
20
- accept,
21
- host: request.host
22
- });
11
+ const acceptHeader = getHeaderValueOrDefault(request, 'accept', 'text/html');
12
+ return await getBestActionFromMitigationAPI(deps, config, netaceaCookie, clientIp, userAgent, acceptHeader, request.host, mitataCaptcha);
23
13
  }
24
14
  //# sourceMappingURL=getMitigationResponse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getMitigationResponse.js","sourceRoot":"","sources":["../../../src/helpers/getMitigationResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAA+B,EAC/B,MAAoC,EACpC,OAAgC;IAEhC,MAAM,OAAO,GAAG,uBAAuB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC1D,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,iBAA2B,CAAC,CAAA;IACjG,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,wBAAkC,CAAC,CAAA;IACxG,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAA;IAClE,MAAM,SAAS,GAAG,uBAAuB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;IAChE,MAAM,MAAM,GAAG,uBAAuB,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAA;IACtE,OAAO,MAAM,sBAAsB,CACjC,IAAI,EACJ,MAAM,EACN;QACE,QAAQ;QACR,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE;QACzB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,aAAa;QACrB,aAAa;QACb,GAAG,EAAE,OAAO,CAAC,IAAI;QACjB,SAAS;QACT,MAAM;QACN,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"getMitigationResponse.js","sourceRoot":"","sources":["../../../src/helpers/getMitigationResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAsB,8BAA8B,EAAE,MAAM,kCAAkC,CAAA;AAErG,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAA+B,EAC/B,MAAoC,EACpC,OAAgC;IAEhC,MAAM,OAAO,GAAG,uBAAuB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC1D,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,iBAA2B,CAAC,CAAA;IACjG,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,wBAAkC,CAAC,CAAA;IACxG,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAA;IAClE,MAAM,SAAS,GAAG,uBAAuB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;IAChE,MAAM,YAAY,GAAG,uBAAuB,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAA;IAE5E,OAAO,MAAM,8BAA8B,CACzC,IAAI,EACJ,MAAM,EACN,aAAa,EACb,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,OAAO,CAAC,IAAI,EACZ,aAAa,CACd,CAAA;AACH,CAAC"}
@@ -3,8 +3,16 @@ export async function inject(deps, config, request) {
3
3
  const result = await getMitigationResponse(deps, config, request);
4
4
  const responseHeaders = {};
5
5
  responseHeaders['set-cookie'] = result.setCookie.join('; ');
6
+ const injectHeaders = {
7
+ 'x-netacea-match': result.bestMitigation.parts.match.toString(),
8
+ 'x-netacea-mitigate': result.bestMitigation.parts.mitigate.toString(),
9
+ 'x-netacea-captcha': result.bestMitigation.parts.captcha.toString()
10
+ };
11
+ if (result.eventId !== undefined) {
12
+ injectHeaders['x-netacea-event-id'] = result.eventId;
13
+ }
6
14
  return {
7
- injectHeaders: result.injectHeaders,
15
+ injectHeaders,
8
16
  sessionStatus: result.sessionStatus,
9
17
  setCookie: result.setCookie,
10
18
  response: {
@@ -1 +1 @@
1
- {"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/helpers/inject.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,IAA+B,EAC/B,MAAoC,EACpC,OAAgC;IAEhC,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACjE,MAAM,eAAe,GAA2B,EAAE,CAAA;IAClD,eAAe,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3D,OAAO;QACL,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,QAAQ,EAAE;YACR,OAAO,EAAE,eAAe;SACzB;KACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/helpers/inject.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,IAA+B,EAC/B,MAAoC,EACpC,OAAgC;IAEhC,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACjE,MAAM,eAAe,GAA2B,EAAE,CAAA;IAClD,eAAe,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAE3D,MAAM,aAAa,GAAkB;QACnC,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE;QAC/D,oBAAoB,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE;QACrE,mBAAmB,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;KACpE,CAAA;IACD,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;QAChC,aAAa,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAC,OAAO,CAAA;KACrD;IAED,OAAO;QACL,aAAa;QACb,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,QAAQ,EAAE;YACR,OAAO,EAAE,eAAe;SACzB;KACF,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netacea/akamai",
3
- "version": "5.0.80",
3
+ "version": "5.0.82",
4
4
  "description": "Netacea Akamai CDN Integration",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "license": "ISC",
22
22
  "dependencies": {
23
- "@netacea/netaceaintegrationbase": "^1.16.86",
23
+ "@netacea/netaceaintegrationbase": "^1.16.88",
24
24
  "buffer": "^6.0.3",
25
25
  "jssha": "^3.3.0"
26
26
  },
@@ -67,5 +67,5 @@
67
67
  "tslib": "^2.0.3",
68
68
  "typescript": "^4.0.3"
69
69
  },
70
- "gitHead": "0dd37124b1512d13ebf936f35831cab3c23796ef"
70
+ "gitHead": "55adcd2ab41834da89f216e570ad4acd3788d601"
71
71
  }
@@ -1,3 +0,0 @@
1
- import type { ComposeResultResponse } from '@netacea/netaceaintegrationbase';
2
- import type { AkamaiRuntimeDependencies, AkamaiWorkerConfig } from '../types';
3
- export declare function check(deps: AkamaiRuntimeDependencies, config: Readonly<AkamaiWorkerConfig>, netaceaCookie: string | undefined, clientIP: string, userAgent: string, accept: string, host: string, captchaCookie?: string): Promise<ComposeResultResponse>;
@@ -1,33 +0,0 @@
1
- import { retrieveCookieInfo } from './retrieveCookieInfo';
2
- import { composeResult } from './composeResult';
3
- import { createProtoMitata } from './createProtoMitata';
4
- import { makeMitigateApiCall } from '../mitigation/makeMitigateApiCall';
5
- export async function check(deps, config, netaceaCookie, clientIP, userAgent, accept, host, captchaCookie) {
6
- let status, match, mitigate, captcha, body, setCookie, eventId;
7
- if (config.secretKey === undefined) {
8
- throw new Error('Secret key is required to mitigate');
9
- }
10
- const cookieInfo = await retrieveCookieInfo(netaceaCookie, clientIP, config.secretKey);
11
- if (!cookieInfo.isPrimaryHashValid || cookieInfo.requiresReissue) {
12
- const result = await makeMitigateApiCall(deps, config, cookieInfo.mitata?.userId, clientIP, userAgent, captchaCookie, accept, host);
13
- status = result.status;
14
- match = result.match;
15
- mitigate = result.mitigate;
16
- captcha = result.captcha;
17
- body = result.body;
18
- setCookie = [
19
- await createProtoMitata(clientIP, cookieInfo.mitata?.userId, match, mitigate, captcha, result.mitataMaxAge)
20
- ];
21
- eventId = result.eventId;
22
- }
23
- else {
24
- status = -1;
25
- match = cookieInfo.match;
26
- mitigate = cookieInfo.mitigate;
27
- captcha = cookieInfo.captcha;
28
- body = undefined;
29
- setCookie = [];
30
- }
31
- return composeResult(config, body, setCookie, status, match, mitigate, captcha, false, eventId);
32
- }
33
- //# sourceMappingURL=check.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/helpers/check.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,E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AA;QACX,KAAK,GAAG,UAAU,CAAC,KAAK,CAAA;QACxB,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAA;QAC9B,OAAO,GAAG,UAAU,CAAC,OAAO,CAAA;QAC5B,IAAI,GAAG,SAAS,CAAA;QAChB,SAAS,GAAG,EAAE,CAAA;KACf;IACD,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AACjG,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { ComposeResultResponse } from '@netacea/netaceaintegrationbase';
2
- import type { AkamaiWorkerConfig } from '../types';
3
- export declare function composeResult(config: Readonly<AkamaiWorkerConfig>, body: string | undefined, setCookie: string[], status: number, match: number, mitigate: number, captcha: number, isCaptchaPost: boolean, eventId?: string): ComposeResultResponse;
@@ -1,31 +0,0 @@
1
- import { dictionary, NetaceaMitigationType } from '@netacea/netaceaintegrationbase';
2
- import { findBestMitigation } from './findBestMitigation';
3
- const { mitigationTypes } = dictionary;
4
- export function composeResult(config, body, setCookie, status, match, mitigate, captcha, isCaptchaPost, eventId) {
5
- const bestMitigation = findBestMitigation(config, match, mitigate, captcha, isCaptchaPost);
6
- const result = {
7
- body,
8
- apiCallStatus: status,
9
- setCookie,
10
- sessionStatus: bestMitigation.sessionStatus,
11
- mitigation: bestMitigation.mitigation,
12
- mitigated: [
13
- mitigationTypes.block,
14
- mitigationTypes.captcha,
15
- mitigationTypes.captchaPass
16
- ].includes(bestMitigation.mitigation)
17
- };
18
- if (config.mitigationType === NetaceaMitigationType.INJECT) {
19
- const injectHeaders = {
20
- 'x-netacea-match': bestMitigation.parts.match.toString(),
21
- 'x-netacea-mitigate': bestMitigation.parts.mitigate.toString(),
22
- 'x-netacea-captcha': bestMitigation.parts.captcha.toString()
23
- };
24
- if (eventId !== undefined) {
25
- injectHeaders['x-netacea-event-id'] = eventId;
26
- }
27
- result.injectHeaders = injectHeaders;
28
- }
29
- return result;
30
- }
31
- //# sourceMappingURL=composeResult.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"composeResult.js","sourceRoot":"","sources":["../../../src/helpers/composeResult.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,MAAM,EAAE,eAAe,EAAE,GAAG,UAAU,CAAA;AAEtC,MAAM,UAAU,aAAa,CAC3B,MAAoC,EACpC,IAAwB,EACxB,SAAmB,EACnB,MAAc,EACd,KAAa,EACb,QAAgB,EAChB,OAAe,EACf,aAAsB,EACtB,OAAgB;IAEhB,MAAM,cAAc,GAAG,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA;IAC1F,MAAM,MAAM,GAA0B;QACpC,IAAI;QACJ,aAAa,EAAE,MAAM;QACrB,SAAS;QACT,aAAa,EAAE,cAAc,CAAC,aAAa;QAC3C,UAAU,EAAE,cAAc,CAAC,UAAU;QACrC,SAAS,EAAE;YACT,eAAe,CAAC,KAAK;YACrB,eAAe,CAAC,OAAO;YACvB,eAAe,CAAC,WAAW;SAC5B,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC;KACtC,CAAA;IACD,IAAI,MAAM,CAAC,cAAc,KAAK,qBAAqB,CAAC,MAAM,EAAE;QAC1D,MAAM,aAAa,GAAkB;YACnC,iBAAiB,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE;YACxD,oBAAoB,EAAE,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE;YAC9D,mBAAmB,EAAE,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;SAC7D,CAAA;QACD,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,aAAa,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAA;SAC9C;QACD,MAAM,CAAC,aAAa,GAAG,aAAa,CAAA;KACrC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { ComposeResultResponse } from '@netacea/netaceaintegrationbase';
2
- import type { AkamaiRuntimeDependencies, AkamaiWorkerConfig } from '../types';
3
- export declare function processCaptcha(deps: AkamaiRuntimeDependencies, config: Readonly<AkamaiWorkerConfig>, netaceaCookie: string | undefined, clientIP: string, userAgent: string, captchaData: any): Promise<ComposeResultResponse>;
@@ -1,7 +0,0 @@
1
- import { composeResult } from './composeResult';
2
- import { makeCaptchaApiCall } from '../mitigation/makeCaptchaApiCall';
3
- export async function processCaptcha(deps, config, netaceaCookie, clientIP, userAgent, captchaData) {
4
- const { status, match, mitigate, captcha, body, setCookie } = await makeCaptchaApiCall(deps, config, netaceaCookie, clientIP, userAgent, captchaData);
5
- return composeResult(config, body, setCookie, status, match, mitigate, captcha, true);
6
- }
7
- //# sourceMappingURL=processCaptcha.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"processCaptcha.js","sourceRoot":"","sources":["../../../src/helpers/processCaptcha.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAErE,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAA+B,EAC/B,MAAoC,EACpC,aAAiC,EACjC,QAAgB,EAChB,SAAiB,EACjB,WAAgB;IAEhB,MAAM,EACJ,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAClD,GAAG,MAAM,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;IAC3F,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;AACvF,CAAC"}
@@ -1,6 +0,0 @@
1
- import type { ProcessMitigateRequestArgs, ComposeResultResponse } from '@netacea/netaceaintegrationbase';
2
- import type { AkamaiRuntimeDependencies, AkamaiWorkerConfig } from '../types';
3
- export declare function processMitigateRequest(deps: AkamaiRuntimeDependencies, config: Readonly<AkamaiWorkerConfig>, args: ProcessMitigateRequestArgs & {
4
- accept: string;
5
- host: string;
6
- }): Promise<ComposeResultResponse>;
@@ -1,10 +0,0 @@
1
- import { check } from './check';
2
- import { processCaptcha } from './processCaptcha';
3
- import { isUrlCaptchaPost } from '../netaceaPaths';
4
- export async function processMitigateRequest(deps, config, args) {
5
- const isCaptchaPost = isUrlCaptchaPost(args.url, args.method);
6
- return await (isCaptchaPost
7
- ? processCaptcha(deps, config, args.mitata, args.clientIp, args.userAgent, await args.getBodyFn())
8
- : check(deps, config, args.mitata, args.clientIp, args.userAgent, args.accept, args.host, args.mitataCaptcha));
9
- }
10
- //# sourceMappingURL=processMitigateRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"processMitigateRequest.js","sourceRoot":"","sources":["../../../src/helpers/processMitigateRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAA+B,EAC/B,MAAoC,EACpC,IAAmE;IAEnE,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAC7D,OAAO,MAAM,CAAC,aAAa;QACzB,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QAClG,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAC9G,CAAA;AACH,CAAC"}