@netacea/captchafeedback 1.2.1 → 1.2.9
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/README.md +2 -1
- package/package.json +17 -6
- package/CHANGELOG.md +0 -35
- package/dist/CaptchaFeedback.d.ts +0 -92
- package/dist/CaptchaFeedback.js +0 -85
- package/dist/CaptchaFeedback.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -5
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -26,7 +26,8 @@ yarn add @netacea/captchafeedback
|
|
|
26
26
|
```typescript
|
|
27
27
|
import Netacea from '@netacea/captchafeedback'
|
|
28
28
|
const netacea = new Netacea({
|
|
29
|
-
apiKey: 'your-api-key'
|
|
29
|
+
apiKey: 'your-api-key',
|
|
30
|
+
secretKey: 'your-secret-key'
|
|
30
31
|
})
|
|
31
32
|
|
|
32
33
|
const { cookies } = await netacea.updateCaptcha({
|
package/package.json
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netacea/captchafeedback",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"description": "CAPTCHA feedback module to send CAPTCHA results back to Netacea.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "npx nyc tape -r ts-node/register -r tsconfig-paths/register './tests/*.test.ts'",
|
|
9
9
|
"lint": "npx eslint . --ext ts",
|
|
10
|
-
"prepublishOnly": "npx tsc --project tsconfig.build.json"
|
|
10
|
+
"prepublishOnly": "npx tsc --project tsconfig.build.json",
|
|
11
|
+
"aws-sso-setup": "node ./scripts/aws_sso_setup.js",
|
|
12
|
+
"login": "bash ./scripts/codeartifact_login.bash"
|
|
11
13
|
},
|
|
12
14
|
"author": "Jack Scotson <jack.scotson@netacea.com> (https://netacea.com)",
|
|
13
15
|
"publishConfig": {
|
|
14
16
|
"access": "public"
|
|
15
17
|
},
|
|
18
|
+
"files": [
|
|
19
|
+
"./dist/captchafeedback/src",
|
|
20
|
+
"./scripts",
|
|
21
|
+
"./CHANGELOG.md"
|
|
22
|
+
],
|
|
16
23
|
"license": "ISC",
|
|
17
24
|
"devDependencies": {
|
|
18
25
|
"@types/node": "^14.11.2",
|
|
@@ -20,8 +27,9 @@
|
|
|
20
27
|
"@types/tape": "^4.13.0",
|
|
21
28
|
"axios": "^0.21.1",
|
|
22
29
|
"eslint": "^6.8.0",
|
|
30
|
+
"ini": "^3.0.1",
|
|
23
31
|
"nyc": "^15.1.0",
|
|
24
|
-
"sinon": "^9.
|
|
32
|
+
"sinon": "^9.2.4",
|
|
25
33
|
"tape": "^5.0.1",
|
|
26
34
|
"ts-node": "^9.0.0",
|
|
27
35
|
"tsconfig-paths": "^3.9.0",
|
|
@@ -30,5 +38,8 @@
|
|
|
30
38
|
"peerDependencies": {
|
|
31
39
|
"axios": "^0.21.1"
|
|
32
40
|
},
|
|
33
|
-
"
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@netacea/netaceaintegrationbase": "^1.11.1"
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "9d025c5c44074d6f586cc8e93c4180c5a3e260c7"
|
|
34
45
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [1.2.1](https://github.com/Netacea/JavascriptATAIntegration/compare/@netacea/captchafeedback@1.2.0...@netacea/captchafeedback@1.2.1) (2022-05-26)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @netacea/captchafeedback
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [1.2.0](https://github.com/Netacea/JavascriptATAIntegration/compare/@netacea/captchafeedback@1.1.0...@netacea/captchafeedback@1.2.0) (2022-04-29)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
### Features
|
|
18
|
-
|
|
19
|
-
* **Akamai:** ING-155: remove all .npmrc files ([07774ad](https://github.com/Netacea/JavascriptATAIntegration/commit/07774ad034a9a3076adae131cf784e1e22fea73e))
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
# 1.1.0 (2021-06-24)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
### Features
|
|
29
|
-
|
|
30
|
-
* **PB-1758:** Captcha feedback module ([47f582d](https://github.com/Netacea/JavascriptATAIntegration/commit/47f582dbc25c250719fbd66daa96fec492bca76f))
|
|
31
|
-
* **PB-1763:** better testing ([d39fb8c](https://github.com/Netacea/JavascriptATAIntegration/commit/d39fb8c5187561d224a094a618f8b7d6543e42c9))
|
|
32
|
-
* **PB-1763:** Fix changelog and README ([0954f60](https://github.com/Netacea/JavascriptATAIntegration/commit/0954f6074e0ab118cb5a6218dfe1302b5ffdf8d5))
|
|
33
|
-
* **PB-1763:** Fixing test ([01edfd4](https://github.com/Netacea/JavascriptATAIntegration/commit/01edfd4d0600de75bc7351a40fbbe3aeec22053d))
|
|
34
|
-
* **PB-1763:** Passing headers correctly. ([006fcef](https://github.com/Netacea/JavascriptATAIntegration/commit/006fceffc0f92e99b605a37833acae9c9c015e3f))
|
|
35
|
-
* **PB-1763:** Remove UAT and add mitserviceUrl test ([9a2151a](https://github.com/Netacea/JavascriptATAIntegration/commit/9a2151a5ed661db449747069a9148d966dcd45a5))
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
export declare type MakeRequest = (args: MakeRequestArgs) => Promise<MakeRequestResponse>;
|
|
2
|
-
export interface CaptchaFeedbackArgs {
|
|
3
|
-
/**
|
|
4
|
-
* API Key provided by Netacea
|
|
5
|
-
*/
|
|
6
|
-
apiKey: string;
|
|
7
|
-
/**
|
|
8
|
-
* OPTIONAL - Mitigation Service URL provided by Netacea
|
|
9
|
-
*/
|
|
10
|
-
mitigationServiceUrl?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Overridable HTTP implementation
|
|
13
|
-
* If this is not provided - AXIOS shoulld be installed as a peer dependency.
|
|
14
|
-
* Error thrown if this is not provided and AXIOS is not installed.
|
|
15
|
-
* Install axios with `npm i axios --save`
|
|
16
|
-
*/
|
|
17
|
-
makeRequest?: MakeRequest;
|
|
18
|
-
}
|
|
19
|
-
export interface UpdateCaptchaArgs {
|
|
20
|
-
/**
|
|
21
|
-
* Incoming clients IP Address
|
|
22
|
-
*/
|
|
23
|
-
clientIp: string;
|
|
24
|
-
/**
|
|
25
|
-
* Event ID that Netacea provided on the `x-netacea-event-id` header
|
|
26
|
-
* This should be the eventID in realtion to the event when a user was served captcha
|
|
27
|
-
*/
|
|
28
|
-
eventId: string;
|
|
29
|
-
/**
|
|
30
|
-
* The entire `cookie` header received from the client
|
|
31
|
-
*/
|
|
32
|
-
cookieHeader: string;
|
|
33
|
-
/**
|
|
34
|
-
* Client's user-agent header
|
|
35
|
-
*/
|
|
36
|
-
userAgent: string;
|
|
37
|
-
/**
|
|
38
|
-
* Result of the captcha
|
|
39
|
-
* Captcha Passed = true
|
|
40
|
-
* Captcha Failed = false
|
|
41
|
-
*/
|
|
42
|
-
result: boolean;
|
|
43
|
-
}
|
|
44
|
-
export interface UpdateCaptchaResponse {
|
|
45
|
-
/**
|
|
46
|
-
* The cookies object should be set as a set-cookie header in your origin server's response
|
|
47
|
-
* There will be a `_mitata` cookie and an optional `_mitatacaptcha` cookie set in this response.
|
|
48
|
-
* They follow the standard set-cookie header format.
|
|
49
|
-
*/
|
|
50
|
-
cookies: string[];
|
|
51
|
-
}
|
|
52
|
-
export interface MakeRequestArgs {
|
|
53
|
-
/**
|
|
54
|
-
* The URL so send the request to. This includes the path.
|
|
55
|
-
*/
|
|
56
|
-
url: string;
|
|
57
|
-
/**
|
|
58
|
-
* HTTP Method
|
|
59
|
-
*/
|
|
60
|
-
method: 'POST';
|
|
61
|
-
/**
|
|
62
|
-
* Key, value of header values.
|
|
63
|
-
* These all need to be sent with the request.
|
|
64
|
-
*/
|
|
65
|
-
headers: {
|
|
66
|
-
[key: string]: string;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Request body to send with the request
|
|
70
|
-
*/
|
|
71
|
-
body: {
|
|
72
|
-
result: boolean;
|
|
73
|
-
eventId: string;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
export interface MakeRequestResponse {
|
|
77
|
-
status: number;
|
|
78
|
-
headers: {
|
|
79
|
-
[key: string]: string;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export default class CaptchaFeedback {
|
|
83
|
-
private readonly apiKey;
|
|
84
|
-
private readonly mitigationServiceUrl;
|
|
85
|
-
private readonly makeRequest?;
|
|
86
|
-
private axios;
|
|
87
|
-
constructor({ apiKey, mitigationServiceUrl, makeRequest }: CaptchaFeedbackArgs);
|
|
88
|
-
updateCaptcha({ clientIp, eventId, cookieHeader, result, userAgent }: UpdateCaptchaArgs): Promise<UpdateCaptchaResponse>;
|
|
89
|
-
private getAxios;
|
|
90
|
-
private makeAxiosRequest;
|
|
91
|
-
private makeOutboundCall;
|
|
92
|
-
}
|
package/dist/CaptchaFeedback.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class CaptchaFeedback {
|
|
4
|
-
constructor({ apiKey, mitigationServiceUrl = 'https://mitigations.netacea.net', makeRequest }) {
|
|
5
|
-
if (apiKey === null || apiKey === undefined) {
|
|
6
|
-
throw new Error('Netacea: apiKey is a required parameter');
|
|
7
|
-
}
|
|
8
|
-
this.apiKey = apiKey;
|
|
9
|
-
this.mitigationServiceUrl = mitigationServiceUrl;
|
|
10
|
-
this.makeRequest = makeRequest;
|
|
11
|
-
}
|
|
12
|
-
async updateCaptcha({ clientIp, eventId, cookieHeader, result, userAgent }) {
|
|
13
|
-
try {
|
|
14
|
-
const response = await this.makeOutboundCall({
|
|
15
|
-
body: {
|
|
16
|
-
eventId,
|
|
17
|
-
result
|
|
18
|
-
},
|
|
19
|
-
headers: {
|
|
20
|
-
'content-type': 'application/json; charset=utf-8',
|
|
21
|
-
'x-netacea-api-key': this.apiKey,
|
|
22
|
-
'x-netacea-client-ip': clientIp,
|
|
23
|
-
'user-agent': userAgent,
|
|
24
|
-
'cookie': cookieHeader
|
|
25
|
-
},
|
|
26
|
-
method: 'POST',
|
|
27
|
-
url: `${this.mitigationServiceUrl}/UpdateCaptcha`
|
|
28
|
-
});
|
|
29
|
-
if (response.status !== 200) {
|
|
30
|
-
throw new Error(`Netacea: Non-200 status code returned from XHR call. Code was ${response.status}`);
|
|
31
|
-
}
|
|
32
|
-
const mitata = response.headers['x-netacea-mitata-value'];
|
|
33
|
-
const mitataExpiry = response.headers['x-netacea-mitata-expiry'];
|
|
34
|
-
const mitataCaptcha = response.headers['x-netacea-mitatacaptcha-value'];
|
|
35
|
-
const mitataCaptchaExpiry = response.headers['x-netacea-mitatacaptcha-expiry'];
|
|
36
|
-
return {
|
|
37
|
-
cookies: [
|
|
38
|
-
`_mitata=${mitata}; Max-Age=${mitataExpiry}; Path=/;`,
|
|
39
|
-
`_mitatacaptcha=${mitataCaptcha}; Max-Age=${mitataCaptchaExpiry}; Path=/;`
|
|
40
|
-
]
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
// eslint-disable-next-line no-console
|
|
45
|
-
console.error(e);
|
|
46
|
-
return {
|
|
47
|
-
cookies: []
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async getAxios() {
|
|
52
|
-
return await Promise.resolve().then(() => require('axios'));
|
|
53
|
-
}
|
|
54
|
-
async makeAxiosRequest({ body, headers, method, url }) {
|
|
55
|
-
if (this.axios === undefined) {
|
|
56
|
-
try {
|
|
57
|
-
// try to lazyload axios
|
|
58
|
-
this.axios = await this.getAxios();
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
// Throw error as axios req wasn't met by `peerDependencies` and makeRequest was not implemented
|
|
62
|
-
throw new Error(['Netacea: Axios must be installed `(npm i axios --save)`',
|
|
63
|
-
'or makeRequest must be provided to override the default of axios being used.'].join(' '));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (method === 'POST') {
|
|
67
|
-
const response = await this.axios.post(url, body, {
|
|
68
|
-
headers
|
|
69
|
-
});
|
|
70
|
-
return {
|
|
71
|
-
status: response.status,
|
|
72
|
-
headers: response.headers
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
throw new Error('Netacea: method not supported');
|
|
76
|
-
}
|
|
77
|
-
async makeOutboundCall(args) {
|
|
78
|
-
if (this.makeRequest !== undefined) {
|
|
79
|
-
return await this.makeRequest(args);
|
|
80
|
-
}
|
|
81
|
-
return await this.makeAxiosRequest(args);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.default = CaptchaFeedback;
|
|
85
|
-
//# sourceMappingURL=CaptchaFeedback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaFeedback.js","sourceRoot":"","sources":["../src/CaptchaFeedback.ts"],"names":[],"mappings":";;AAqFA,MAAqB,eAAe;IAKlC,YAAa,EACX,MAAM,EACN,oBAAoB,GAAG,iCAAiC,EACxD,WAAW,EACS;QACpB,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;SAC3D;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAA;QAChD,IAAI,CAAC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,QAAQ;QACpB,OAAO,2CAAa,OAAO,EAA2B,CAAA;IACxD,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAE,EAC9B,IAAI,EACJ,OAAO,EACP,MAAM,EACN,GAAG,EACa;QAChB,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,IAAI;gBACF,wBAAwB;gBACxB,IAAI,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAA;aACnC;YAAC,MAAM;gBACN,gGAAgG;gBAChG,MAAM,IAAI,KAAK,CAAC,CAAC,yDAAyD;oBACxE,8EAA8E,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;aAC7F;SACF;QACD,IAAI,MAAM,KAAK,MAAM,EAAE;YACrB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE;gBAChD,OAAO;aACR,CAAC,CAAA;YACF,OAAO;gBACL,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,OAAO,EAAE,QAAQ,CAAC,OAAO;aAC1B,CAAA;SACF;QACD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAE,IAAqB;QACnD,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;YAClC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;SACpC;QACD,OAAO,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;IAC1C,CAAC;CACF;AArGD,kCAqGC"}
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,uDAA+C;AAC/C,kBAAe,yBAAe,CAAA"}
|