@deflectbot/deflect-sdk 1.2.0 → 1.2.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +7 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deflectbot/deflect-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
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
@@ -46,6 +46,7 @@ class Deflect {
46
46
  try {
47
47
  this.scriptCache = await this.fetchScript();
48
48
  } catch {
49
+ /* empty */
49
50
  } finally {
50
51
  this.isWarmupInProgress = false;
51
52
  }
@@ -95,12 +96,18 @@ class Deflect {
95
96
 
96
97
  const token = await this.getTokenFromScript();
97
98
 
99
+ this.prefetchNextScript();
100
+
98
101
  return token;
99
102
  } finally {
100
103
  this.cleanup(blobUrl, scriptElement);
101
104
  }
102
105
  }
103
106
 
107
+ private prefetchNextScript(): void {
108
+ this.tryWarmup().catch(() => {});
109
+ }
110
+
104
111
  private createReadyPromise(): Promise<void> {
105
112
  return new Promise<void>((resolve) => {
106
113
  if (typeof window !== "undefined") {