@deflectbot/deflect-sdk 1.1.6 → 1.1.8

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/dist/index.js CHANGED
@@ -35,8 +35,11 @@ class Deflect {
35
35
  if (!window.Deflect.siteKey) {
36
36
  throw new Error("API key (siteKey) is missing in configuration");
37
37
  }
38
- const scriptUrl = `https://js.deflect.bot/main.js?sitekey=${window.Deflect.siteKey}`;
39
- const response = yield fetch(scriptUrl);
38
+ const nonce = Date.now().toString();
39
+ const scriptUrl = `https://js.deflect.bot/main.js?sitekey=${window.Deflect.siteKey}&_=${nonce}`;
40
+ const response = yield fetch(scriptUrl, {
41
+ cache: "no-store",
42
+ });
40
43
  if (!response.ok) {
41
44
  throw new Error("Failed to fetch the Deflect script");
42
45
  }
@@ -47,7 +50,8 @@ class Deflect {
47
50
  const scriptEl = document.createElement("script");
48
51
  scriptEl.type = "module";
49
52
  const blob = new Blob([yield response.text()], { type: "text/javascript" });
50
- scriptEl.src = URL.createObjectURL(blob);
53
+ const blobUrl = URL.createObjectURL(blob);
54
+ scriptEl.src = blobUrl;
51
55
  document.head.appendChild(scriptEl);
52
56
  yield new Promise((resolve, reject) => {
53
57
  scriptEl.onload = () => resolve();
@@ -59,6 +63,11 @@ class Deflect {
59
63
  throw new Error("Deflect script did not load properly");
60
64
  }
61
65
  const token = yield window.Deflect.getToken();
66
+ URL.revokeObjectURL(blobUrl);
67
+ scriptEl.remove();
68
+ // Optional: wipe memory-heavy fields
69
+ delete window.Deflect.getToken;
70
+ delete window.Deflect.ready;
62
71
  return token;
63
72
  });
64
73
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@deflectbot/deflect-sdk",
3
- "version": "1.1.6",
4
- "description": "",
3
+ "version": "1.1.8",
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",
7
7
  "scripts": {
8
8
  "build": "tsc"
9
9
  },
10
- "author": "Fredrik Rafn",
10
+ "author": "Deflect",
11
11
  "license": "MIT",
12
12
  "devDependencies": {
13
13
  "@eslint/js": "^9.22.0",
package/src/index.ts CHANGED
@@ -33,8 +33,13 @@ class Deflect {
33
33
  throw new Error("API key (siteKey) is missing in configuration");
34
34
  }
35
35
 
36
- const scriptUrl = `https://js.deflect.bot/main.js?sitekey=${window.Deflect.siteKey}`;
37
- const response = await fetch(scriptUrl);
36
+ const nonce = Date.now().toString();
37
+ const scriptUrl = `https://js.deflect.bot/main.js?sitekey=${window.Deflect.siteKey}&_=${nonce}`;
38
+ const response = await fetch(scriptUrl,
39
+ {
40
+ cache: "no-store",
41
+ }
42
+ );
38
43
 
39
44
  if (!response.ok) {
40
45
  throw new Error("Failed to fetch the Deflect script");
@@ -49,7 +54,8 @@ class Deflect {
49
54
  scriptEl.type = "module";
50
55
 
51
56
  const blob = new Blob([await response.text()], { type: "text/javascript" });
52
- scriptEl.src = URL.createObjectURL(blob);
57
+ const blobUrl = URL.createObjectURL(blob);
58
+ scriptEl.src = blobUrl;
53
59
 
54
60
  document.head.appendChild(scriptEl);
55
61
 
@@ -68,6 +74,13 @@ class Deflect {
68
74
  }
69
75
 
70
76
  const token = await window.Deflect.getToken();
77
+ URL.revokeObjectURL(blobUrl);
78
+ scriptEl.remove();
79
+
80
+ // Optional: wipe memory-heavy fields
81
+ delete window.Deflect.getToken;
82
+ delete window.Deflect.ready;
83
+
71
84
  return token;
72
85
  }
73
86