@friendlycaptcha/server-sdk 0.1.0 → 0.1.2
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/.github/workflows/ci.yml +3 -0
- package/CHANGELOG.md +8 -0
- package/README.md +76 -3
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/client/client.js +1 -1
- package/dist/client/client.js.map +1 -1
- package/dist/client/result.d.ts +1 -1
- package/dist/client/result.js +2 -2
- package/dist/client/result.js.map +1 -1
- package/dist/client/version.gen.d.ts +1 -1
- package/dist/client/version.gen.js +1 -1
- package/example/README.md +29 -0
- package/example/package-lock.json +1404 -0
- package/example/package.json +24 -0
- package/example/src/index.ts +84 -0
- package/example/tsconfig.json +13 -0
- package/example/views/index.ejs +86 -0
- package/package.json +3 -2
- package/src/api/index.ts +1 -1
- package/src/client/client.ts +5 -2
- package/src/client/errors.ts +7 -7
- package/src/client/index.ts +1 -1
- package/src/client/result.ts +8 -7
- package/src/client/version.gen.ts +1 -1
- package/test/client/client.test.ts +11 -12
package/.github/workflows/ci.yml
CHANGED
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# friendly-captcha-javascript
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@friendlycaptcha/server-sdk)
|
|
4
|
+
|
|
3
5
|
A Javascript client for the [Friendly Captcha](https://friendlycaptcha.com) service. This client allows for easy integration and verification of captcha responses with the Friendly Captcha API.
|
|
4
6
|
|
|
5
7
|
> This library is for [Friendly Captcha v2](https://developer.friendlycaptcha.com) only. If you are looking for V1, look [here](https://docs.friendlycaptcha.com)
|
|
@@ -16,23 +18,94 @@ npm install @friendlycaptcha/server-sdk
|
|
|
16
18
|
|
|
17
19
|
## Usage
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
Below are some basic examples of how to use the client.
|
|
22
|
+
|
|
23
|
+
For a more detailed example, take a look at the [example](./example) directory.
|
|
24
|
+
|
|
25
|
+
### Initialization
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
import { FriendlyCaptchaClient } from "@friendlycaptcha/server-sdk";
|
|
29
|
+
|
|
30
|
+
const frcClient = new FriendlyCaptchaClient({
|
|
31
|
+
apiKey: "YOUR_API_KEY",
|
|
32
|
+
sitekey: "YOUR_SITEKEY",
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Verifying a Captcha Response
|
|
37
|
+
|
|
38
|
+
After calling `verifyCaptchaResponse` with the captcha response there are two functions on the result object that you should check:
|
|
39
|
+
|
|
40
|
+
- `wasAbleToVerify()` indicates whether we were able to verify the captcha response. This will be `false` in case there was an issue with the network/our service or if there was a mistake in the configuration.
|
|
41
|
+
- `shouldAccept()` indicates whether the captcha response was correct. If the client is running in non-strict mode (default) and `wasAbleToVerify()` returned `false`, this will be `true`.
|
|
42
|
+
|
|
43
|
+
Below are some examples of this behaviour.
|
|
44
|
+
|
|
45
|
+
#### Verifying a correct captcha response without issues when veryfing:
|
|
20
46
|
|
|
21
47
|
```javascript
|
|
22
|
-
|
|
48
|
+
const result = await frcClient.verifyCaptchaResponse("CORRECT_CAPTCHA_RESPONSE_HERE");
|
|
49
|
+
console.log(result.wasAbleToVerify()); // true
|
|
50
|
+
console.log(result.shouldAccept()); // true
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Verifying an incorrect captcha response without issues when veryfing:
|
|
23
54
|
|
|
24
|
-
|
|
55
|
+
```javascript
|
|
56
|
+
const result = await frcClient.verifyCaptchaResponse("INCORRECT_CAPTCHA_RESPONSE_HERE");
|
|
57
|
+
console.log(result.wasAbleToVerify()); // true
|
|
58
|
+
console.log(result.shouldAccept()); // false
|
|
25
59
|
```
|
|
26
60
|
|
|
61
|
+
#### Verifying an incorrect captcha response with issues (network issues or bad configuration) when veryfing in non-strict mode (default):
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
const result = await frcClient.verifyCaptchaResponse("INCORRECT_CAPTCHA_RESPONSE_HERE");
|
|
65
|
+
console.log(result.wasAbleToVerify()); // false
|
|
66
|
+
console.log(result.shouldAccept()); // true
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Verifying an incorrect captcha response with issues (network/service issues or bad configuration) when veryfing in strict mode:
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
const frcClient = new FriendlyCaptchaClient({
|
|
73
|
+
...
|
|
74
|
+
strict: true,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const result = await frcClient.verifyCaptchaResponse("INCORRECT_CAPTCHA_RESPONSE_HERE");
|
|
78
|
+
console.log(result.wasAbleToVerify()); // false
|
|
79
|
+
console.log(result.shouldAccept()); // false
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Configuration
|
|
83
|
+
|
|
84
|
+
### Configuration
|
|
85
|
+
|
|
86
|
+
The client offers several configuration options:
|
|
87
|
+
|
|
88
|
+
- **apiKey**: Your Friendly Captcha API key.
|
|
89
|
+
- **sitekey**: Your Friendly Captcha sitekey.
|
|
90
|
+
- **strict**: (Optional) In case the client was not able to verify the captcha response at all (for example if there is a network failure or a mistake in configuration), by default `verifyCaptchaResponse` returns `true` regardless. By passing `strict: true`, it will return `false` instead: every response needs to be strictly verified.
|
|
91
|
+
- **siteverifyEndpoint**: (Optional) The endpoint URL for the site verification API. Shorthands `eu` or `global` are also accepted. Default is `global`.
|
|
92
|
+
- **fetch**: (Optional) The fetch implementation to use. Defaults to `globalThis.fetch`.
|
|
93
|
+
|
|
27
94
|
## Development
|
|
28
95
|
|
|
29
96
|
### Install dependencies
|
|
97
|
+
|
|
30
98
|
```shell
|
|
31
99
|
npm install
|
|
32
100
|
```
|
|
33
101
|
|
|
34
102
|
### Run the tests
|
|
103
|
+
|
|
104
|
+
First run the SDK Test server, then run `npm test`.
|
|
105
|
+
|
|
35
106
|
```shell
|
|
107
|
+
docker run -p 1090:1090 friendlycaptcha/sdk-testserver:latest
|
|
108
|
+
|
|
36
109
|
npm test
|
|
37
110
|
```
|
|
38
111
|
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./types";
|
|
1
|
+
export * from "./types.js";
|
package/dist/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./types";
|
|
1
|
+
export * from "./types.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
package/dist/client/client.js
CHANGED
|
@@ -53,7 +53,7 @@ export class FriendlyCaptchaClient {
|
|
|
53
53
|
const headers = {
|
|
54
54
|
"Content-Type": "application/json",
|
|
55
55
|
Accept: "application/json",
|
|
56
|
-
"
|
|
56
|
+
"Frc-Sdk": "friendly-captcha-javascript-sdk@" + SDK_VERSION,
|
|
57
57
|
"X-Api-Key": this.apiKey,
|
|
58
58
|
};
|
|
59
59
|
const timeout = (opts === null || opts === void 0 ? void 0 : opts.timeout) || 20000;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/client/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAC/B,oCAAoC,EACpC,2BAA2B,EAC3B,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAiC/C,MAAM,0BAA0B,GAAG,qDAAqD,CAAC;AACzF,MAAM,sBAAsB,GAAG,iDAAiD,C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,CAAC;oBAC9D,OAAO,CAAC,MAAM,CAAC,CAAC;oBAChB,OAAO;iBACR;gBACD,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACvB,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACX,MAAM,CAAC,eAAe,GAAG,yBAAyB,CAAC;gBACnD,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/client/result.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SiteverifyErrorResponseErrorData, SiteverifyResponse } from "../api";
|
|
1
|
+
import type { SiteverifyErrorResponseErrorData, SiteverifyResponse } from "../api/index.js";
|
|
2
2
|
import { VerifyClientErrorCode } from "./errors.js";
|
|
3
3
|
/**
|
|
4
4
|
* The result of a captcha siteverify request.
|
package/dist/client/result.js
CHANGED
|
@@ -74,7 +74,7 @@ export class VerifyResult {
|
|
|
74
74
|
* Something went wrong making the request to the Friendly Captcha API, perhaps there is a network connection issue?
|
|
75
75
|
*/
|
|
76
76
|
isRequestOrTimeoutError() {
|
|
77
|
-
return this.clientErrorType === REQUEST_FAILED_ERROR_CODE || this.clientErrorType === REQUEST_FAILED_TIMEOUT_ERROR_CODE;
|
|
77
|
+
return (this.clientErrorType === REQUEST_FAILED_ERROR_CODE || this.clientErrorType === REQUEST_FAILED_TIMEOUT_ERROR_CODE);
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Something went wrong decoding the response from the Friendly Captcha API.
|
|
@@ -113,7 +113,7 @@ export class VerifyResult {
|
|
|
113
113
|
* If this is false, you should notify yourself and use `getErrorCode()` and `getResponseError()` to see what is wrong.
|
|
114
114
|
*/
|
|
115
115
|
wasAbleToVerify() {
|
|
116
|
-
// If we failed to encode, we actually consider `wasAbleToVerify` to be true. This is because we don't want to
|
|
116
|
+
// If we failed to encode, we actually consider `wasAbleToVerify` to be true. This is because we don't want to
|
|
117
117
|
// alert on failed encoding: an attacker could send such malformed data that it fails to encode.
|
|
118
118
|
if (this.isEncodeError()) {
|
|
119
119
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/client/result.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAC/B,oCAAoC,EACpC,2BAA2B,EAC3B,yBAAyB,EACzB,iCAAiC,GAElC,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,OAAO,YAAY;
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/client/result.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAC/B,oCAAoC,EACpC,2BAA2B,EAC3B,yBAAyB,EACzB,iCAAiC,GAElC,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAcvB,YAAY,MAAe;QAZ3B;;;WAGG;QACI,WAAM,GAAW,CAAC,CAAC,CAAC;QAE3B;;WAEG;QACI,aAAQ,GAA8B,IAAI,CAAC;QAC3C,oBAAe,GAAiC,IAAI,CAAC;QAG1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,YAAY;QACjB,IAAI,IAAI,CAAC,eAAe,EAAE,EAAE;YAC1B,gGAAgG;YAChG,6GAA6G;YAC7G,qCAAqC;YACrC,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE;gBACxB,OAAO,KAAK,CAAC;aACd;YAED,OAAO,IAAI,CAAC,QAAS,CAAC,OAAO,KAAK,IAAI,CAAC;SACxC;QACD,IAAI,IAAI,CAAC,eAAe,KAAK,IAAI,EAAE;YACjC,IAAI,IAAI,CAAC,MAAM,EAAE;gBACf,yCAAyC;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Ae;QACpB,8GAA8G;QAC9G,gGAAgG;QAChG,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE;YACxB,OAAO,IAAI,CAAC;SACb;QAED,8FAA8F;QAC9F,OAAO,IAAI,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IACzF,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.1.
|
|
1
|
+
export declare const SDK_VERSION = "0.1.2";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Friendly Captcha Express Example
|
|
2
|
+
|
|
3
|
+
This application integrates Friendly Captcha for form submissions using Express.
|
|
4
|
+
|
|
5
|
+
### Requirements
|
|
6
|
+
|
|
7
|
+
- NPM
|
|
8
|
+
- Your Friendly Captcha API key and sitekey.
|
|
9
|
+
|
|
10
|
+
### Start the application
|
|
11
|
+
|
|
12
|
+
- Install dependencies
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- Setup env variables and start the application
|
|
19
|
+
|
|
20
|
+
> NOTE: `FRC_SITEVERIFY_ENDPOINT` and `FRC_WIDGET_ENDPOINT` are optional. If not set, the default values will be used. You can also use `global` or `eu` as shorthands for both.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
FRC_APIKEY=<your API key> FRC_SITEKEY=<your sitekey> FRC_SITEVERIFY_ENDPOINT=<siteverify endpoint> FRC_WIDGET_ENDPOINT=<widget endpoint> npm run start
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
# Usage
|
|
27
|
+
|
|
28
|
+
Navigate to http://localhost:3000/ in your browser.
|
|
29
|
+
Fill out the form and submit. The Friendly Captcha verification will protect the form from bots.
|