@deflectbot/deflect-sdk 1.1.15 → 1.1.16

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
@@ -27,11 +27,11 @@ npm install deflect
27
27
  ## Setup
28
28
 
29
29
  ```ts
30
- import Deflect from "@deflectbot/deflect-sdk";
30
+ import Deflect from '@deflectbot/deflect-sdk';
31
31
 
32
32
  Deflect.configure({
33
- siteKey: "YOUR_SITE_KEY",
34
- extraArgs: { mode: "strict" }, // Optional
33
+ actionId: 'YOUR_ACTION_ID',
34
+ extraArgs: { mode: 'strict' }, // Optional
35
35
  forceRefresh: true, // Optional
36
36
  });
37
37
  ```
@@ -43,8 +43,8 @@ Deflect.configure({
43
43
  ```ts
44
44
  try {
45
45
  const token = await Deflect.solveChallenge();
46
- console.log("✅ Token received:", token);
46
+ console.log('✅ Token received:', token);
47
47
  } catch (error) {
48
- console.error("❌ Failed to solve challenge:", error);
48
+ console.error('❌ Failed to solve challenge:', error);
49
49
  }
50
- ```
50
+ ```
package/dist/index.js CHANGED
@@ -22,10 +22,10 @@ class Deflect {
22
22
  }
23
23
  }
24
24
  _warmupScript() {
25
- if (!window.Deflect.siteKey)
25
+ if (!window.Deflect.actionId)
26
26
  return;
27
27
  const nonce = Date.now().toString();
28
- const scriptUrl = `https://js.deflect.bot/main.js?sitekey=${window.Deflect.siteKey}&_=${nonce}`;
28
+ const scriptUrl = `https://js.deflect.bot/main.js?action_id=${window.Deflect.actionId}&_=${nonce}`;
29
29
  fetch(scriptUrl, { cache: "no-store" })
30
30
  .then((res) => __awaiter(this, void 0, void 0, function* () {
31
31
  if (!res.ok)
@@ -45,16 +45,16 @@ class Deflect {
45
45
  };
46
46
  }
47
47
  configure(params) {
48
- if (!params.siteKey) {
49
- throw new Error("siteKey is required in configuration");
48
+ if (!params.actionId) {
49
+ throw new Error("actionId is required in configuration");
50
50
  }
51
- window.Deflect.siteKey = params.siteKey;
51
+ window.Deflect.actionId = params.actionId;
52
52
  }
53
53
  solveChallenge() {
54
54
  return __awaiter(this, void 0, void 0, function* () {
55
55
  var _a;
56
- if (!window.Deflect.siteKey) {
57
- throw new Error("API key (siteKey) is missing in configuration");
56
+ if (!window.Deflect.actionId) {
57
+ throw new Error("actionId is missing in configuration");
58
58
  }
59
59
  this.setupReady();
60
60
  let scriptText;
@@ -65,7 +65,7 @@ class Deflect {
65
65
  }
66
66
  else {
67
67
  const nonce = Date.now().toString();
68
- const scriptUrl = `https://js.deflect.bot/main.js?sitekey=${window.Deflect.siteKey}&_=${nonce}`;
68
+ const scriptUrl = `https://js.deflect.bot/main.js?action_id=${window.Deflect.actionId}&_=${nonce}`;
69
69
  const response = yield fetch(scriptUrl, { cache: "no-store" });
70
70
  if (!response.ok) {
71
71
  throw new Error("Failed to fetch the Deflect script");
@@ -1,5 +1,5 @@
1
1
  interface DeflectConfig {
2
- siteKey: string;
2
+ actionId: string;
3
3
  extraArgs?: {
4
4
  [key: string]: string;
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deflectbot/deflect-sdk",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "description": "SDK for deflect.bot - Use it for seamless captcha integration on any website.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  interface DeflectConfig {
2
- siteKey: string;
2
+ actionId: string;
3
3
  extraArgs?: { [key: string]: string };
4
4
  }
5
5
 
@@ -21,10 +21,10 @@ class Deflect {
21
21
  }
22
22
 
23
23
  private _warmupScript(): void {
24
- if (!window.Deflect.siteKey) return;
24
+ if (!window.Deflect.actionId) return;
25
25
 
26
26
  const nonce = Date.now().toString();
27
- const scriptUrl = `https://js.deflect.bot/main.js?sitekey=${window.Deflect.siteKey}&_=${nonce}`;
27
+ const scriptUrl = `https://js.deflect.bot/main.js?action_id=${window.Deflect.actionId}&_=${nonce}`;
28
28
  fetch(scriptUrl, { cache: "no-store" })
29
29
  .then(async (res) => {
30
30
  if (!res.ok) return;
@@ -45,15 +45,15 @@ class Deflect {
45
45
  }
46
46
 
47
47
  configure(params: DeflectConfig): void {
48
- if (!params.siteKey) {
49
- throw new Error("siteKey is required in configuration");
48
+ if (!params.actionId) {
49
+ throw new Error("actionId is required in configuration");
50
50
  }
51
- window.Deflect.siteKey = params.siteKey;
51
+ window.Deflect.actionId = params.actionId;
52
52
  }
53
53
 
54
54
  async solveChallenge(): Promise<string> {
55
- if (!window.Deflect.siteKey) {
56
- throw new Error("API key (siteKey) is missing in configuration");
55
+ if (!window.Deflect.actionId) {
56
+ throw new Error("actionId is missing in configuration");
57
57
  }
58
58
 
59
59
  this.setupReady();
@@ -66,7 +66,7 @@ class Deflect {
66
66
  this._hasUsedPrefetch = true;
67
67
  } else {
68
68
  const nonce = Date.now().toString();
69
- const scriptUrl = `https://js.deflect.bot/main.js?sitekey=${window.Deflect.siteKey}&_=${nonce}`;
69
+ const scriptUrl = `https://js.deflect.bot/main.js?action_id=${window.Deflect.actionId}&_=${nonce}`;
70
70
  const response = await fetch(scriptUrl, { cache: "no-store" });
71
71
 
72
72
  if (!response.ok) {