@friendlycaptcha/server-sdk 0.1.2 → 0.2.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/api/types.d.ts +13 -1
  4. package/dist/api/typesRiskIntelligence.d.ts +778 -0
  5. package/dist/api/typesRiskIntelligence.js +25 -0
  6. package/dist/api/typesRiskIntelligence.js.map +1 -0
  7. package/dist/client/client.d.ts +15 -0
  8. package/dist/client/client.js +28 -8
  9. package/dist/client/client.js.map +1 -1
  10. package/dist/client/version.gen.d.ts +1 -1
  11. package/dist/client/version.gen.js +1 -1
  12. package/dist/index.d.ts +829 -0
  13. package/package.json +16 -2
  14. package/.github/workflows/ci.yml +0 -50
  15. package/.github/workflows/publish.yml +0 -18
  16. package/.prettierrc +0 -3
  17. package/docs/index.md +0 -12
  18. package/docs/server-sdk.failed_due_to_client_error_code.md +0 -15
  19. package/docs/server-sdk.failed_to_decode_response_error_code.md +0 -13
  20. package/docs/server-sdk.failed_to_encode_error_code.md +0 -13
  21. package/docs/server-sdk.friendlycaptchaclient._constructor_.md +0 -20
  22. package/docs/server-sdk.friendlycaptchaclient.md +0 -26
  23. package/docs/server-sdk.friendlycaptchaclient.verifycaptcharesponse.md +0 -30
  24. package/docs/server-sdk.friendlycaptchaoptions.apikey.md +0 -13
  25. package/docs/server-sdk.friendlycaptchaoptions.fetch.md +0 -13
  26. package/docs/server-sdk.friendlycaptchaoptions.md +0 -24
  27. package/docs/server-sdk.friendlycaptchaoptions.sitekey.md +0 -11
  28. package/docs/server-sdk.friendlycaptchaoptions.siteverifyendpoint.md +0 -15
  29. package/docs/server-sdk.friendlycaptchaoptions.strict.md +0 -15
  30. package/docs/server-sdk.md +0 -41
  31. package/docs/server-sdk.request_failed_error_code.md +0 -13
  32. package/docs/server-sdk.request_failed_timeout_error_code.md +0 -13
  33. package/docs/server-sdk.siteverifyerrorresponse.error.md +0 -11
  34. package/docs/server-sdk.siteverifyerrorresponse.md +0 -20
  35. package/docs/server-sdk.siteverifyerrorresponse.success.md +0 -11
  36. package/docs/server-sdk.siteverifyerrorresponseerrordata.detail.md +0 -11
  37. package/docs/server-sdk.siteverifyerrorresponseerrordata.error_code.md +0 -11
  38. package/docs/server-sdk.siteverifyerrorresponseerrordata.md +0 -20
  39. package/docs/server-sdk.siteverifyresponse.md +0 -14
  40. package/docs/server-sdk.siteverifyresponsechallengedata.md +0 -20
  41. package/docs/server-sdk.siteverifyresponsechallengedata.origin.md +0 -13
  42. package/docs/server-sdk.siteverifyresponsechallengedata.timestamp.md +0 -13
  43. package/docs/server-sdk.siteverifyresponsedata.challenge.md +0 -11
  44. package/docs/server-sdk.siteverifyresponsedata.md +0 -19
  45. package/docs/server-sdk.siteverifysuccessresponse.data.md +0 -11
  46. package/docs/server-sdk.siteverifysuccessresponse.md +0 -20
  47. package/docs/server-sdk.siteverifysuccessresponse.success.md +0 -11
  48. package/docs/server-sdk.verifyclienterrorcode.md +0 -14
  49. package/docs/server-sdk.verifyresult._constructor_.md +0 -20
  50. package/docs/server-sdk.verifyresult.clienterrortype.md +0 -11
  51. package/docs/server-sdk.verifyresult.geterrorcode.md +0 -15
  52. package/docs/server-sdk.verifyresult.getresponse.md +0 -17
  53. package/docs/server-sdk.verifyresult.getresponseerror.md +0 -17
  54. package/docs/server-sdk.verifyresult.isclienterror.md +0 -19
  55. package/docs/server-sdk.verifyresult.isdecodeerror.md +0 -17
  56. package/docs/server-sdk.verifyresult.isencodeerror.md +0 -17
  57. package/docs/server-sdk.verifyresult.isrequestortimeouterror.md +0 -17
  58. package/docs/server-sdk.verifyresult.isstrict.md +0 -17
  59. package/docs/server-sdk.verifyresult.md +0 -44
  60. package/docs/server-sdk.verifyresult.response.md +0 -13
  61. package/docs/server-sdk.verifyresult.shouldaccept.md +0 -17
  62. package/docs/server-sdk.verifyresult.shouldreject.md +0 -17
  63. package/docs/server-sdk.verifyresult.status.md +0 -13
  64. package/docs/server-sdk.verifyresult.wasabletoverify.md +0 -17
  65. package/example/README.md +0 -29
  66. package/example/package-lock.json +0 -1404
  67. package/example/package.json +0 -24
  68. package/example/src/index.ts +0 -84
  69. package/example/tsconfig.json +0 -13
  70. package/example/views/index.ejs +0 -86
  71. package/src/api/errors.ts +0 -77
  72. package/src/api/index.ts +0 -1
  73. package/src/api/types.ts +0 -66
  74. package/src/client/client.ts +0 -157
  75. package/src/client/errors.ts +0 -42
  76. package/src/client/index.ts +0 -3
  77. package/src/client/result.ts +0 -152
  78. package/src/client/version.gen.ts +0 -3
  79. package/src/index.ts +0 -2
  80. package/test/client/client.test.ts +0 -47
  81. package/test/client/mock.test.ts +0 -44
  82. package/tsconfig.json +0 -20
@@ -1,11 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [SiteverifySuccessResponse](./server-sdk.siteverifysuccessresponse.md) &gt; [success](./server-sdk.siteverifysuccessresponse.success.md)
4
-
5
- ## SiteverifySuccessResponse.success property
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- success: true;
11
- ```
@@ -1,14 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyClientErrorCode](./server-sdk.verifyclienterrorcode.md)
4
-
5
- ## VerifyClientErrorCode type
6
-
7
-
8
- **Signature:**
9
-
10
- ```typescript
11
- export type VerifyClientErrorCode = typeof FAILED_TO_ENCODE_ERROR_CODE | typeof REQUEST_FAILED_ERROR_CODE | typeof REQUEST_FAILED_TIMEOUT_ERROR_CODE | typeof FAILED_DUE_TO_CLIENT_ERROR_CODE | typeof FAILED_TO_DECODE_RESPONSE_ERROR_CODE;
12
- ```
13
- **References:** [FAILED\_TO\_ENCODE\_ERROR\_CODE](./server-sdk.failed_to_encode_error_code.md)<!-- -->, [REQUEST\_FAILED\_ERROR\_CODE](./server-sdk.request_failed_error_code.md)<!-- -->, [REQUEST\_FAILED\_TIMEOUT\_ERROR\_CODE](./server-sdk.request_failed_timeout_error_code.md)<!-- -->, [FAILED\_DUE\_TO\_CLIENT\_ERROR\_CODE](./server-sdk.failed_due_to_client_error_code.md)<!-- -->, [FAILED\_TO\_DECODE\_RESPONSE\_ERROR\_CODE](./server-sdk.failed_to_decode_response_error_code.md)
14
-
@@ -1,20 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [(constructor)](./server-sdk.verifyresult._constructor_.md)
4
-
5
- ## VerifyResult.(constructor)
6
-
7
- Constructs a new instance of the `VerifyResult` class
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- constructor(strict: boolean);
13
- ```
14
-
15
- ## Parameters
16
-
17
- | Parameter | Type | Description |
18
- | --- | --- | --- |
19
- | strict | boolean | |
20
-
@@ -1,11 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [clientErrorType](./server-sdk.verifyresult.clienterrortype.md)
4
-
5
- ## VerifyResult.clientErrorType property
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- clientErrorType: VerifyClientErrorCode | null;
11
- ```
@@ -1,15 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [getErrorCode](./server-sdk.verifyresult.geterrorcode.md)
4
-
5
- ## VerifyResult.getErrorCode() method
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- getErrorCode(): VerifyClientErrorCode | null;
11
- ```
12
- **Returns:**
13
-
14
- [VerifyClientErrorCode](./server-sdk.verifyclienterrorcode.md) \| null
15
-
@@ -1,17 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [getResponse](./server-sdk.verifyresult.getresponse.md)
4
-
5
- ## VerifyResult.getResponse() method
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- getResponse(): SiteverifyResponse | null;
11
- ```
12
- **Returns:**
13
-
14
- [SiteverifyResponse](./server-sdk.siteverifyresponse.md) \| null
15
-
16
- The response from the Friendly Captcha API, or null if the request was not made at all.
17
-
@@ -1,17 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [getResponseError](./server-sdk.verifyresult.getresponseerror.md)
4
-
5
- ## VerifyResult.getResponseError() method
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- getResponseError(): SiteverifyErrorResponseErrorData | null;
11
- ```
12
- **Returns:**
13
-
14
- [SiteverifyErrorResponseErrorData](./server-sdk.siteverifyerrorresponseerrordata.md) \| null
15
-
16
- The `error` field form the response, or null if it is not present.
17
-
@@ -1,19 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [isClientError](./server-sdk.verifyresult.isclienterror.md)
4
-
5
- ## VerifyResult.isClientError() method
6
-
7
- Something went wrong on the client side, this generally means your configuration is wrong. Check your secrets (API key) and sitekey.
8
-
9
- See `getResponseError()` for more information.
10
-
11
- **Signature:**
12
-
13
- ```typescript
14
- isClientError(): boolean;
15
- ```
16
- **Returns:**
17
-
18
- boolean
19
-
@@ -1,17 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [isDecodeError](./server-sdk.verifyresult.isdecodeerror.md)
4
-
5
- ## VerifyResult.isDecodeError() method
6
-
7
- Something went wrong decoding the response from the Friendly Captcha API.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- isDecodeError(): boolean;
13
- ```
14
- **Returns:**
15
-
16
- boolean
17
-
@@ -1,17 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [isEncodeError](./server-sdk.verifyresult.isencodeerror.md)
4
-
5
- ## VerifyResult.isEncodeError() method
6
-
7
- Was unable to encode the captcha response. This means the captcha response was invalid and should never be accepted.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- isEncodeError(): boolean;
13
- ```
14
- **Returns:**
15
-
16
- boolean
17
-
@@ -1,17 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [isRequestOrTimeoutError](./server-sdk.verifyresult.isrequestortimeouterror.md)
4
-
5
- ## VerifyResult.isRequestOrTimeoutError() method
6
-
7
- Something went wrong making the request to the Friendly Captcha API, perhaps there is a network connection issue?
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- isRequestOrTimeoutError(): boolean;
13
- ```
14
- **Returns:**
15
-
16
- boolean
17
-
@@ -1,17 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [isStrict](./server-sdk.verifyresult.isstrict.md)
4
-
5
- ## VerifyResult.isStrict() method
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- isStrict(): boolean;
11
- ```
12
- **Returns:**
13
-
14
- boolean
15
-
16
- Whether strict mode was enabled for this verification.
17
-
@@ -1,44 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md)
4
-
5
- ## VerifyResult class
6
-
7
- The result of a captcha siteverify request.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- export declare class VerifyResult
13
- ```
14
-
15
- ## Constructors
16
-
17
- | Constructor | Modifiers | Description |
18
- | --- | --- | --- |
19
- | [(constructor)(strict)](./server-sdk.verifyresult._constructor_.md) | | Constructs a new instance of the <code>VerifyResult</code> class |
20
-
21
- ## Properties
22
-
23
- | Property | Modifiers | Type | Description |
24
- | --- | --- | --- | --- |
25
- | [clientErrorType](./server-sdk.verifyresult.clienterrortype.md) | | [VerifyClientErrorCode](./server-sdk.verifyclienterrorcode.md) \| null | |
26
- | [response](./server-sdk.verifyresult.response.md) | | [SiteverifyResponse](./server-sdk.siteverifyresponse.md) \| null | The response from the Friendly Captcha API, or null if the request was not made at all. |
27
- | [status](./server-sdk.verifyresult.status.md) | | number | The HTTP status code of the response. <code>-1</code> if there was no response. |
28
-
29
- ## Methods
30
-
31
- | Method | Modifiers | Description |
32
- | --- | --- | --- |
33
- | [getErrorCode()](./server-sdk.verifyresult.geterrorcode.md) | | |
34
- | [getResponse()](./server-sdk.verifyresult.getresponse.md) | | |
35
- | [getResponseError()](./server-sdk.verifyresult.getresponseerror.md) | | |
36
- | [isClientError()](./server-sdk.verifyresult.isclienterror.md) | | <p>Something went wrong on the client side, this generally means your configuration is wrong. Check your secrets (API key) and sitekey.</p><p>See <code>getResponseError()</code> for more information.</p> |
37
- | [isDecodeError()](./server-sdk.verifyresult.isdecodeerror.md) | | Something went wrong decoding the response from the Friendly Captcha API. |
38
- | [isEncodeError()](./server-sdk.verifyresult.isencodeerror.md) | | Was unable to encode the captcha response. This means the captcha response was invalid and should never be accepted. |
39
- | [isRequestOrTimeoutError()](./server-sdk.verifyresult.isrequestortimeouterror.md) | | Something went wrong making the request to the Friendly Captcha API, perhaps there is a network connection issue? |
40
- | [isStrict()](./server-sdk.verifyresult.isstrict.md) | | |
41
- | [shouldAccept()](./server-sdk.verifyresult.shouldaccept.md) | | |
42
- | [shouldReject()](./server-sdk.verifyresult.shouldreject.md) | | |
43
- | [wasAbleToVerify()](./server-sdk.verifyresult.wasabletoverify.md) | | Whether the request to verify the captcha was completed. In other words: the API responded with status 200.' If this is false, you should notify yourself and use <code>getErrorCode()</code> and <code>getResponseError()</code> to see what is wrong. |
44
-
@@ -1,13 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [response](./server-sdk.verifyresult.response.md)
4
-
5
- ## VerifyResult.response property
6
-
7
- The response from the Friendly Captcha API, or null if the request was not made at all.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- response: SiteverifyResponse | null;
13
- ```
@@ -1,17 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [shouldAccept](./server-sdk.verifyresult.shouldaccept.md)
4
-
5
- ## VerifyResult.shouldAccept() method
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- shouldAccept(): boolean;
11
- ```
12
- **Returns:**
13
-
14
- boolean
15
-
16
- Whether the captcha should be accepted. Note that this does not necessarily mean it was verified.
17
-
@@ -1,17 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [shouldReject](./server-sdk.verifyresult.shouldreject.md)
4
-
5
- ## VerifyResult.shouldReject() method
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- shouldReject(): boolean;
11
- ```
12
- **Returns:**
13
-
14
- boolean
15
-
16
- The reverse of `shouldAccept()`<!-- -->.
17
-
@@ -1,13 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [status](./server-sdk.verifyresult.status.md)
4
-
5
- ## VerifyResult.status property
6
-
7
- The HTTP status code of the response. `-1` if there was no response.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- status: number;
13
- ```
@@ -1,17 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@friendlycaptcha/server-sdk](./server-sdk.md) &gt; [VerifyResult](./server-sdk.verifyresult.md) &gt; [wasAbleToVerify](./server-sdk.verifyresult.wasabletoverify.md)
4
-
5
- ## VerifyResult.wasAbleToVerify() method
6
-
7
- Whether the request to verify the captcha was completed. In other words: the API responded with status 200.' If this is false, you should notify yourself and use `getErrorCode()` and `getResponseError()` to see what is wrong.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- wasAbleToVerify(): boolean;
13
- ```
14
- **Returns:**
15
-
16
- boolean
17
-
package/example/README.md DELETED
@@ -1,29 +0,0 @@
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.