@netacea/captchafeedback 1.2.17 → 1.3.0
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,38 @@
|
|
|
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
|
+
# [1.3.0](https://github.com/Netacea/JavascriptATAIntegration/compare/@netacea/captchafeedback@1.2.18...@netacea/captchafeedback@1.3.0) (2023-02-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **Captcha Feedback Library:** PE2-377: Added debug cookie header + version bump ([e09efbb](https://github.com/Netacea/JavascriptATAIntegration/commit/e09efbb387cc4a25a23efd44bdbd4792a107f500))
|
|
12
|
+
* **Captcha Feedback Library:** PE2-377: Added encryption and version bump ([091884a](https://github.com/Netacea/JavascriptATAIntegration/commit/091884ab5c377b817150b0bd5a6bad1b575705e9))
|
|
13
|
+
* **Captcha Feedback Library:** PE2-377: Added renaming of the cookie before making captcha update call ([d176cf3](https://github.com/Netacea/JavascriptATAIntegration/commit/d176cf3de8fc3ac1321dc1d57f0492c5788eaa43))
|
|
14
|
+
* **Captcha Feedback Library:** PE2-377: Adjust naming + bump version ([771290a](https://github.com/Netacea/JavascriptATAIntegration/commit/771290ad052a77b8a0f3f5fee867965de468db9b))
|
|
15
|
+
* **Captcha Feedback Library:** PE2-377: Bump version ([6e9ccd0](https://github.com/Netacea/JavascriptATAIntegration/commit/6e9ccd002369ec2865c775d1b3b4f2b138b09a36))
|
|
16
|
+
* **Captcha Feedback Library:** PE2-377: Changed cookie names back to default ([3d9b635](https://github.com/Netacea/JavascriptATAIntegration/commit/3d9b6352860a3f04a85fcf751b22b787fa80fd1f))
|
|
17
|
+
* **Captcha Feedback Library:** PE2-377: Changed naming of the cookies variables and amended replacement ([5262e37](https://github.com/Netacea/JavascriptATAIntegration/commit/5262e377d8c6b4f8873b21e10e8c8d8a6fbd03c6))
|
|
18
|
+
* **Captcha Feedback Library:** PE2-377: Checking different default cookies values ([0c58d68](https://github.com/Netacea/JavascriptATAIntegration/commit/0c58d68acdfff292269673c155da55446d785d90))
|
|
19
|
+
* **Captcha Feedback Library:** PE2-377: Cleaning ([ac41e78](https://github.com/Netacea/JavascriptATAIntegration/commit/ac41e7863d7ed5a6a2872e0bfa81e698b451ca4a))
|
|
20
|
+
* **Captcha Feedback Library:** PE2-377: Removing encryption and enabling custom cookies handling ([262476e](https://github.com/Netacea/JavascriptATAIntegration/commit/262476e0ef7df9e5b9be92d8b9973932fd53dbf7))
|
|
21
|
+
* **Captcha Feedback Library:** PE2-377: Reverting back to default cookie names ([bb0ff8c](https://github.com/Netacea/JavascriptATAIntegration/commit/bb0ff8c0797de668feaab4e43a482e3d4501c98f))
|
|
22
|
+
* **Captcha Feedback Library:** PE2-377: Reverting changes to test site ([ff1d548](https://github.com/Netacea/JavascriptATAIntegration/commit/ff1d54825e419ad26a3ce6b9673789bb96b37581))
|
|
23
|
+
* **Captcha Feedback Library:** PE2-377: Some initial changes ([2e1fd3d](https://github.com/Netacea/JavascriptATAIntegration/commit/2e1fd3dc1ce3c0e52d490813de054625dbeac7cd))
|
|
24
|
+
* **Captcha Feedback Library:** PE2-377: Version de-bump ([96c52dd](https://github.com/Netacea/JavascriptATAIntegration/commit/96c52dd77fa2943d1d412c1fec22cfbc66106167))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [1.2.18](https://github.com/Netacea/JavascriptATAIntegration/compare/@netacea/captchafeedback@1.2.17...@netacea/captchafeedback@1.2.18) (2023-02-14)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @netacea/captchafeedback
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [1.2.17](https://github.com/Netacea/JavascriptATAIntegration/compare/@netacea/captchafeedback@1.2.16...@netacea/captchafeedback@1.2.17) (2023-02-03)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @netacea/captchafeedback
|
|
@@ -11,6 +11,14 @@ export interface CaptchaFeedbackArgs {
|
|
|
11
11
|
* Secret Key provided by Netacea
|
|
12
12
|
*/
|
|
13
13
|
secretKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* OPTIONAL - custom Mitata cookie name
|
|
16
|
+
*/
|
|
17
|
+
netaceaCookieName?: string;
|
|
18
|
+
/**
|
|
19
|
+
* OPTIONAL - custom Mitata Captcha cookie name
|
|
20
|
+
*/
|
|
21
|
+
netaceaCaptchaCookieName?: string;
|
|
14
22
|
/**
|
|
15
23
|
* OPTIONAL - Mitigation Service URL provided by Netacea
|
|
16
24
|
*/
|
|
@@ -83,6 +91,7 @@ export interface UpdateCaptchaResponse {
|
|
|
83
91
|
/**
|
|
84
92
|
* The cookies object should be set as a set-cookie header in your origin server's response
|
|
85
93
|
* There will be a `_mitata` cookie and an optional `_mitatacaptcha` cookie set in this response.
|
|
94
|
+
* If you set the names of the cookies to some custom values then the cookies will be called different.
|
|
86
95
|
* They follow the standard set-cookie header format.
|
|
87
96
|
*/
|
|
88
97
|
cookies: string[];
|
|
@@ -120,12 +129,14 @@ export interface MakeRequestResponse {
|
|
|
120
129
|
export default class CaptchaFeedback {
|
|
121
130
|
private readonly apiKey;
|
|
122
131
|
private readonly secretKey;
|
|
132
|
+
private readonly netaceaCookieName;
|
|
133
|
+
private readonly netaceaCaptchaCookieName;
|
|
123
134
|
private readonly mitigationServiceUrl;
|
|
124
135
|
private readonly makeRequest?;
|
|
125
136
|
private readonly createMitataCookie?;
|
|
126
137
|
private readonly matchMitataCookie?;
|
|
127
138
|
private axios;
|
|
128
|
-
constructor({ apiKey, secretKey, mitigationServiceUrl, makeRequest, createMitataCookie, matchMitataCookie }: CaptchaFeedbackArgs);
|
|
139
|
+
constructor({ apiKey, secretKey, netaceaCookieName, netaceaCaptchaCookieName, mitigationServiceUrl, makeRequest, createMitataCookie, matchMitataCookie }: CaptchaFeedbackArgs);
|
|
129
140
|
private makeUpdateCaptchaCall;
|
|
130
141
|
updateCaptcha({ clientIp, eventId, cookieHeader, result, userAgent }: UpdateCaptchaArgs): Promise<UpdateCaptchaResponse>;
|
|
131
142
|
private parseCookie;
|
|
@@ -2,18 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const netaceaintegrationbase_1 = require("@netacea/netaceaintegrationbase");
|
|
4
4
|
class CaptchaFeedback {
|
|
5
|
-
constructor({ apiKey, secretKey, mitigationServiceUrl = 'https://mitigations.netacea.net', makeRequest, createMitataCookie, matchMitataCookie }) {
|
|
5
|
+
constructor({ apiKey, secretKey, netaceaCookieName = '_mitata', netaceaCaptchaCookieName = '_mitatacaptcha', mitigationServiceUrl = 'https://mitigations.netacea.net', makeRequest, createMitataCookie, matchMitataCookie }) {
|
|
6
6
|
if (apiKey === null || apiKey === undefined) {
|
|
7
7
|
throw new Error('Netacea: apiKey is a required parameter');
|
|
8
8
|
}
|
|
9
9
|
this.apiKey = apiKey;
|
|
10
10
|
this.secretKey = secretKey;
|
|
11
|
+
this.netaceaCookieName = netaceaCookieName;
|
|
12
|
+
this.netaceaCaptchaCookieName = netaceaCaptchaCookieName;
|
|
11
13
|
this.mitigationServiceUrl = mitigationServiceUrl;
|
|
12
14
|
this.makeRequest = makeRequest;
|
|
13
15
|
this.createMitataCookie = createMitataCookie;
|
|
14
16
|
this.matchMitataCookie = matchMitataCookie;
|
|
15
17
|
}
|
|
16
18
|
async makeUpdateCaptchaCall({ eventId, result, clientIp, userAgent, cookieHeader, userId }) {
|
|
19
|
+
cookieHeader = cookieHeader.replace(`${this.netaceaCookieName}=`, '_mitata=');
|
|
17
20
|
const response = await this.makeOutboundCall({
|
|
18
21
|
body: {
|
|
19
22
|
eventId,
|
|
@@ -40,7 +43,9 @@ class CaptchaFeedback {
|
|
|
40
43
|
// from getting values out of headers which isn't adding complex logic
|
|
41
44
|
async updateCaptcha({ clientIp, eventId, cookieHeader, result, userAgent }) {
|
|
42
45
|
var _a;
|
|
43
|
-
if (cookieHeader === undefined ||
|
|
46
|
+
if (cookieHeader === undefined ||
|
|
47
|
+
cookieHeader.length === 0 ||
|
|
48
|
+
!cookieHeader.includes(`${this.netaceaCookieName}=`)) {
|
|
44
49
|
throw new Error('The cookie header must have a mitata cookie');
|
|
45
50
|
}
|
|
46
51
|
try {
|
|
@@ -66,8 +71,8 @@ class CaptchaFeedback {
|
|
|
66
71
|
const newCookie = this.createCookie(clientIp, userId, Math.floor(Date.now() / 1000) + 60, this.secretKey, `${mitataMatch}${mitataMitigate}${mitataCaptcha}`);
|
|
67
72
|
return {
|
|
68
73
|
cookies: [
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
`${this.netaceaCookieName}=${newCookie}; Max-Age=${mitataExpiry}; Path=/;`,
|
|
75
|
+
`${this.netaceaCaptchaCookieName}=${mitataCaptchaValue}; Max-Age=${mitataCaptchaExpiry}; Path=/;`
|
|
71
76
|
]
|
|
72
77
|
};
|
|
73
78
|
}
|
|
@@ -79,7 +84,7 @@ class CaptchaFeedback {
|
|
|
79
84
|
}
|
|
80
85
|
/* eslint-enable max-lines-per-function */
|
|
81
86
|
parseCookie(cookieHeader) {
|
|
82
|
-
const parsedCookieHeader = cookieHeader.substring(
|
|
87
|
+
const parsedCookieHeader = cookieHeader.substring(`${this.netaceaCookieName}=`.length);
|
|
83
88
|
const trimedParsedCookieHeader = parsedCookieHeader.includes('; Max-Age=')
|
|
84
89
|
? parsedCookieHeader.split(';')[0] : parsedCookieHeader;
|
|
85
90
|
return trimedParsedCookieHeader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaFeedback.js","sourceRoot":"","sources":["../../../src/CaptchaFeedback.ts"],"names":[],"mappings":";;AAGA,4EAAqG;
|
|
1
|
+
{"version":3,"file":"Captcha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EAChC,MAAM,EACN,UAAU,EACV,OAAO,EACP,OAAO,CAAC,CAAA;IACZ,CAAC;IAEO,WAAW,CAAE,MAAc;QACjC,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE;YACxC,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;SACtC;QACD,OAAO,0CAAiB,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;CACF;AArMD,kCAqMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netacea/captchafeedback",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "CAPTCHA feedback module to send CAPTCHA results back to Netacea.",
|
|
5
5
|
"main": "dist/captchafeedback/src/index.js",
|
|
6
6
|
"types": "dist/captchafeedback/src/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"axios": "^0.21.1"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@netacea/netaceaintegrationbase": "^1.
|
|
41
|
+
"@netacea/netaceaintegrationbase": "^1.15.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "ee8d4b1e04ed2bd01674ae296b15c41fee242209"
|
|
44
44
|
}
|