@netacea/cloudfront 5.2.53 → 6.0.1

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/package.json DELETED
@@ -1,51 +0,0 @@
1
- {
2
- "name": "@netacea/cloudfront",
3
- "version": "5.2.53",
4
- "description": "Netacea Cloudfront CDN integration",
5
- "main": "dist/src/index.js",
6
- "types": "dist/src/index.d.ts",
7
- "scripts": {
8
- "test": "npm run test:unit && npm run test:integration:no-clean",
9
- "test:integration": "NODE_OPTIONS='--import tsx' npx nyc -r=lcov -r=html -r=text mocha --timeout 60000 './tests/mocha/CloudFrontIntegration.test.ts'",
10
- "test:integration:no-clean": "NODE_OPTIONS='--import tsx' npx nyc --no-clean -r=lcov -r=html -r=text mocha --timeout 60000 './tests/mocha/CloudFrontIntegration.test.ts'",
11
- "test:unit": "NODE_OPTIONS='--import tsx' npx nyc -r=lcov -r=html -r=text tape './tests/tape/*.test.ts'",
12
- "test:regression": "NODE_OPTIONS='--import tsx' npx nyc -r=lcov -r=html -r=text tape './regression_tests/*.test.ts'",
13
- "lint": "npx eslint . --ext ts",
14
- "lint:fix": "npx eslint . --ext ts --fix",
15
- "prepublishOnly": "npm run build",
16
- "build": "npx tsc --project tsconfig.build.json",
17
- "postpack": "npx netacea-bundler postpack",
18
- "prepack": "npx netacea-bundler prepack"
19
- },
20
- "author": "Netacea <npm@netacea.com> (https://netacea.com)",
21
- "publishConfig": {
22
- "access": "public"
23
- },
24
- "license": "ISC",
25
- "devDependencies": {
26
- "@netacea/bundler": "^1.0.0",
27
- "@netacea/kinesisingest": "^1.5.53",
28
- "@netacea/test-runner-scenarios": "^1.0.0",
29
- "@types/chai": "^4.3.5",
30
- "@types/mocha": "^10.0.1",
31
- "@types/node": "^14.11.2",
32
- "@types/proxyquire": "^1.3.28",
33
- "@types/sinon": "^9.0.8",
34
- "@types/tape": "^4.13.0",
35
- "aws-sdk": "^2.763.0",
36
- "chai": "^4.3.7",
37
- "mocha": "^10.2.0",
38
- "nyc": "^15.1.0",
39
- "proxyquire": "^2.1.3",
40
- "sinon": "^9.1.0",
41
- "tape": "^5.0.1",
42
- "ts-node": "^9.0.0",
43
- "typescript": "^5.4.5"
44
- },
45
- "dependencies": {
46
- "@netacea/netaceaintegrationbase": "^2.0.35",
47
- "axios": "^0.21.0",
48
- "jose": "^4.11.2"
49
- },
50
- "gitHead": "c1946ccdfdec28c1030fe76cd3442eea92f14cc5"
51
- }
@@ -1,93 +0,0 @@
1
- import { NetaceaIngestType, NetaceaLogVersion, NetaceaMitigationType, type APICallResponse, type ComposeResultResponse, type FindBestMitigationResponse, type IngestArgs, type InjectResponse, type MakeRequestArgs, type MitigateResponse, type NetaceaMitigationResponse, type NetaceaResponseBase, type ProcessMitigateRequestArgs, type V2WebLog, type WebLog } from '@netacea/netaceaintegrationbase';
2
- import NetaceaKinesis from '@netacea/kinesisingest';
3
- import type { RequestArgs, CloudfrontConstructorArgs, CloudfrontEvent, CloudfrontResponse } from './types';
4
- interface MakeRequestResponse {
5
- status: number;
6
- headers: Record<string, string | string[]>;
7
- body?: any;
8
- }
9
- export default class Cloudfront {
10
- static NetaceaCookieHeader: string;
11
- static NetaceaTrueUserAgentHeader: string;
12
- private readonly cookieEncryptionKey;
13
- ingestEnabled: boolean;
14
- private readonly netaceaCaptchaPath?;
15
- private readonly captchaHeader?;
16
- private readonly dynamicCaptchaContentType;
17
- private readonly ipHeaderName?;
18
- protected mitataCookieExpirySeconds: number;
19
- protected apiKey: string;
20
- protected secretKey?: string;
21
- protected mitigationServiceUrl: string;
22
- protected ingestServiceUrl: string;
23
- protected readonly timeout: number;
24
- protected readonly captchaSiteKey?: string;
25
- protected readonly captchaSecretKey?: string;
26
- protected readonly ingestType: NetaceaIngestType;
27
- protected readonly logVersion: NetaceaLogVersion;
28
- protected readonly kinesis?: NetaceaKinesis;
29
- protected readonly mitigationType: NetaceaMitigationType;
30
- protected readonly encryptedCookies: string[];
31
- protected readonly netaceaCookieName: string;
32
- protected readonly netaceaCaptchaCookieName: string;
33
- protected readonly netaceaCookieAttributes: string;
34
- protected readonly netaceaCaptchaCookieAttributes: string;
35
- constructor(options: CloudfrontConstructorArgs);
36
- run(cloudfrontEvent: CloudfrontEvent): Promise<CloudfrontEvent>;
37
- protected makeRequest({ host, path, method, body, headers, timeout }: MakeRequestArgs): Promise<MakeRequestResponse>;
38
- protected mitigate(cloudfrontEvent: CloudfrontEvent): Promise<MitigateResponse<CloudfrontResponse>>;
39
- protected inject(cloudfrontEvent: CloudfrontEvent): Promise<InjectResponse>;
40
- ingest(cloudfrontEvent: CloudfrontEvent): Promise<any>;
41
- addNetaceaCookiesToResponse(cloudfrontEvent: CloudfrontEvent): void;
42
- private setInjectHeaders;
43
- private getValueFromHeaderOrDefault;
44
- private getMitataValueFromHeaderOrDefault;
45
- private getRequestResponseFromEvent;
46
- private getMitigationResponse;
47
- private addNetaceaCookiesToRequest;
48
- getCookieHeader(args: CloudfrontEvent): string | null;
49
- protected encryptCookieValue(cookieValue: string): Promise<string>;
50
- protected decryptCookieValue(encryptedCookieValue: string): Promise<string>;
51
- /**
52
- * START -- NETACEA BASE METHODS
53
- */
54
- runMitigation(args: RequestArgs): Promise<NetaceaMitigationResponse<CloudfrontResponse>>;
55
- /**
56
- * Returns the value of the cookie with the given name from a string or list of cookies.
57
- * If the cookie name is included in the encryptedCookies class property,
58
- * then the cookie value will be decrypted automatically.
59
- * The method may operate of either the HTTP Cookie or Set-Cookie headers.
60
- * @param cookieName the name of the cookie to find.
61
- * @param cookies the full list of cookies, either as a string or an array of strings.
62
- * @returns the value of the cookie, if found.
63
- */
64
- protected readCookie(cookieName: string, cookies: string | string[] | null | undefined): Promise<string | undefined>;
65
- protected processMitigateRequest(args: ProcessMitigateRequestArgs & {
66
- accept: string;
67
- host: string;
68
- }): Promise<ComposeResultResponse>;
69
- protected isUrlCaptchaPost(url: string, method: string): boolean;
70
- protected isUrlCaptchaGet(url: string, method: string): boolean;
71
- protected shouldSetCaptchaPass(cloudfrontEvent: CloudfrontEvent): boolean;
72
- private processCaptcha;
73
- private makeCaptchaAPICall;
74
- private getApiCallResponseFromResponse;
75
- protected APIError(response: APICallResponse): Error;
76
- protected createMitata(clientIP: string, userId: string | undefined, match: number, mitigate: number, captcha: number, maxAge?: number, expiry?: number | undefined): Promise<string>;
77
- protected createMitataCaptcha(headers: Record<string, string | string[]>): Promise<string | undefined>;
78
- private buildCookieFromValues;
79
- protected callIngest(args: IngestArgs): Promise<void>;
80
- protected constructWebLog(args: IngestArgs): WebLog | V2WebLog;
81
- private constructV2WebLog;
82
- private constructV1WebLog;
83
- private makeIngestApiCall;
84
- protected processIngest(args: RequestArgs): Promise<NetaceaResponseBase>;
85
- protected setIngestOnlyMitataCookie(userId: string | undefined): Promise<NetaceaResponseBase>;
86
- protected findBestMitigation(match: number, mitigate: number, captcha: number, isCaptchaPost: boolean): FindBestMitigationResponse;
87
- private adjustCaptchaCode;
88
- protected check(netaceaCookie: string | undefined, clientIP: string, userAgent: string, accept: string, host: string, captchaCookie?: string): Promise<ComposeResultResponse>;
89
- private makeMitigateAPICall;
90
- private buildCookieHeader;
91
- private composeResult;
92
- }
93
- export {};