@captchafox/node 1.1.1 → 1.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.
package/README.md CHANGED
@@ -18,6 +18,10 @@ yarn add @captchafox/node
18
18
  pnpm add @captchafox/node
19
19
  ```
20
20
 
21
+ ```sh
22
+ bun add @captchafox/node
23
+ ```
24
+
21
25
  ## Usage
22
26
 
23
27
  ### ESM / await
@@ -29,16 +33,15 @@ const secret = 'organization_secret';
29
33
  const token = 'widget_token';
30
34
 
31
35
  try {
32
- const data = await verify(secret, token);
33
- if (data.success) {
34
- console.log('success!', data);
35
- } else {
36
- console.log('verification failed');
37
- }
38
- } catch(error) {
39
- console.log(error);
36
+ const data = await verify(secret, token);
37
+ if (data.success) {
38
+ console.log('success!', data);
39
+ } else {
40
+ console.log('verification failed');
41
+ }
42
+ } catch (error) {
43
+ console.log(error);
40
44
  }
41
-
42
45
  ```
43
46
 
44
47
  ### Require
package/dist/index.d.mts CHANGED
@@ -20,10 +20,12 @@ type VerifyPayload = NodeJS.Dict<string> & {
20
20
  secret: string;
21
21
  /** The response token from the widget */
22
22
  response: string;
23
- /** (Optional) the sitekey that was use to issue the token */
23
+ /** (Optional) The sitekey that was used to issue the token */
24
24
  sitekey?: string;
25
+ /** (Optional) The IP address of the requesting user */
26
+ remoteIp?: string;
25
27
  };
26
- declare function verify(secret: string, token: string, sitekey?: string): Promise<VerifyResponse>;
28
+ declare function verify(secret: string, token: string, sitekey?: string, remoteIp?: string): Promise<VerifyResponse>;
27
29
 
28
30
  declare const CAPTCHA_RESPONSE_KEY = "cf-captcha-response";
29
31
 
package/dist/index.d.ts CHANGED
@@ -20,10 +20,12 @@ type VerifyPayload = NodeJS.Dict<string> & {
20
20
  secret: string;
21
21
  /** The response token from the widget */
22
22
  response: string;
23
- /** (Optional) the sitekey that was use to issue the token */
23
+ /** (Optional) The sitekey that was used to issue the token */
24
24
  sitekey?: string;
25
+ /** (Optional) The IP address of the requesting user */
26
+ remoteIp?: string;
25
27
  };
26
- declare function verify(secret: string, token: string, sitekey?: string): Promise<VerifyResponse>;
28
+ declare function verify(secret: string, token: string, sitekey?: string, remoteIp?: string): Promise<VerifyResponse>;
27
29
 
28
30
  declare const CAPTCHA_RESPONSE_KEY = "cf-captcha-response";
29
31
 
package/dist/index.js CHANGED
@@ -30,12 +30,15 @@ var import_https = require("https");
30
30
  var import_querystring = require("querystring");
31
31
  var HOST = "api.captchafox.com";
32
32
  var API_PATH = "/siteverify";
33
- async function verify(secret, token, sitekey) {
33
+ async function verify(secret, token, sitekey, remoteIp) {
34
34
  return new Promise(function verifyPromise(resolve, reject) {
35
35
  const payload = { secret, response: token };
36
36
  if (sitekey) {
37
37
  payload.sitekey = sitekey;
38
38
  }
39
+ if (remoteIp) {
40
+ payload.remoteIp = remoteIp;
41
+ }
39
42
  const data = (0, import_querystring.stringify)(payload);
40
43
  const options = {
41
44
  host: HOST,
package/dist/index.mjs CHANGED
@@ -3,12 +3,15 @@ import { request } from "https";
3
3
  import { stringify } from "querystring";
4
4
  var HOST = "api.captchafox.com";
5
5
  var API_PATH = "/siteverify";
6
- async function verify(secret, token, sitekey) {
6
+ async function verify(secret, token, sitekey, remoteIp) {
7
7
  return new Promise(function verifyPromise(resolve, reject) {
8
8
  const payload = { secret, response: token };
9
9
  if (sitekey) {
10
10
  payload.sitekey = sitekey;
11
11
  }
12
+ if (remoteIp) {
13
+ payload.remoteIp = remoteIp;
14
+ }
12
15
  const data = stringify(payload);
13
16
  const options = {
14
17
  host: HOST,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@captchafox/node",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "devDependencies": {
33
33
  "@captchafox/tsconfig": "*",
34
34
  "@captchafox/internal": "*",
35
- "@types/jest": "^29.5.5",
35
+ "@jest/globals": "^29.7.0",
36
36
  "@types/node": "^18.13.0",
37
37
  "jest": "^29.7.0",
38
38
  "nock": "^13.3.3",
@@ -40,6 +40,10 @@
40
40
  "ts-jest": "^29.1.1",
41
41
  "typescript": "^5.0.2"
42
42
  },
43
+ "keywords": [
44
+ "node",
45
+ "captchafox"
46
+ ],
43
47
  "repository": {
44
48
  "type": "git",
45
49
  "url": "https://github.com/CaptchaFox/javascript-integrations.git",