@deflectbot/deflect-sdk 1.1.14 → 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,17 +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;
52
- console.log("Deflect configured with siteKey");
51
+ window.Deflect.actionId = params.actionId;
53
52
  }
54
53
  solveChallenge() {
55
54
  return __awaiter(this, void 0, void 0, function* () {
56
55
  var _a;
57
- if (!window.Deflect.siteKey) {
58
- throw new Error("API key (siteKey) is missing in configuration");
56
+ if (!window.Deflect.actionId) {
57
+ throw new Error("actionId is missing in configuration");
59
58
  }
60
59
  this.setupReady();
61
60
  let scriptText;
@@ -66,7 +65,7 @@ class Deflect {
66
65
  }
67
66
  else {
68
67
  const nonce = Date.now().toString();
69
- 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}`;
70
69
  const response = yield fetch(scriptUrl, { cache: "no-store" });
71
70
  if (!response.ok) {
72
71
  throw new Error("Failed to fetch the Deflect script");
@@ -97,8 +96,7 @@ class Deflect {
97
96
  token = yield window.Deflect.getToken();
98
97
  }
99
98
  catch (error) {
100
- console.error("Error during Deflect script execution:", error);
101
- throw new Error("Deflect script execution failed");
99
+ throw new Error(`Deflect script execution failed: ${error}`);
102
100
  }
103
101
  URL.revokeObjectURL(blobUrl);
104
102
  scriptEl.remove();
@@ -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.14",
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,16 +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;
52
- console.log("Deflect configured with siteKey");
51
+ window.Deflect.actionId = params.actionId;
53
52
  }
54
53
 
55
54
  async solveChallenge(): Promise<string> {
56
- if (!window.Deflect.siteKey) {
57
- throw new Error("API key (siteKey) is missing in configuration");
55
+ if (!window.Deflect.actionId) {
56
+ throw new Error("actionId is missing in configuration");
58
57
  }
59
58
 
60
59
  this.setupReady();
@@ -67,7 +66,7 @@ class Deflect {
67
66
  this._hasUsedPrefetch = true;
68
67
  } else {
69
68
  const nonce = Date.now().toString();
70
- 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}`;
71
70
  const response = await fetch(scriptUrl, { cache: "no-store" });
72
71
 
73
72
  if (!response.ok) {
@@ -110,8 +109,7 @@ class Deflect {
110
109
  try {
111
110
  token = await window.Deflect.getToken();
112
111
  } catch (error) {
113
- console.error("Error during Deflect script execution:", error);
114
- throw new Error("Deflect script execution failed");
112
+ throw new Error(`Deflect script execution failed: ${error}`);
115
113
  }
116
114
 
117
115
  URL.revokeObjectURL(blobUrl);