@dtect/security-sdk-js 0.0.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.
- package/README.md +206 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Security API Javascript SDK
|
|
2
|
+
|
|
3
|
+
Security API Javascript SDK by dtect.
|
|
4
|
+
|
|
5
|
+
<!-- TABLE OF CONTENTS -->
|
|
6
|
+
<details>
|
|
7
|
+
<summary>Table of Contents</summary>
|
|
8
|
+
<ol>
|
|
9
|
+
<li>
|
|
10
|
+
<a href="#about-the-project">About The Project</a>
|
|
11
|
+
</li>
|
|
12
|
+
<li>
|
|
13
|
+
<a href="#getting-started">Getting Started</a>
|
|
14
|
+
<ul>
|
|
15
|
+
<li><a href="#prerequisites">Prerequisites</a></li>
|
|
16
|
+
<li><a href="#installation">Installation</a></li>
|
|
17
|
+
</ul>
|
|
18
|
+
</li>
|
|
19
|
+
<li>
|
|
20
|
+
<a href="#implementation">Implementation</a>
|
|
21
|
+
</li>
|
|
22
|
+
<li>
|
|
23
|
+
<a href="#errors">Errors</a>
|
|
24
|
+
</li>
|
|
25
|
+
<li><a href="#license">License</a></li>
|
|
26
|
+
<li><a href="#contact">Contact</a></li>
|
|
27
|
+
</ol>
|
|
28
|
+
</details>
|
|
29
|
+
|
|
30
|
+
<!-- ABOUT THE PROJECT -->
|
|
31
|
+
|
|
32
|
+
## About The Project
|
|
33
|
+
|
|
34
|
+
Security API SDK
|
|
35
|
+
|
|
36
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
37
|
+
|
|
38
|
+
<!-- GETTING STARTED -->
|
|
39
|
+
|
|
40
|
+
## Getting Started
|
|
41
|
+
|
|
42
|
+
The dtect Security API helps you gather valuable insights about your visitors, enhancing the quality of your survey data.
|
|
43
|
+
This library is responsible for collecting data about the visitor's browser and behavior, send everything to our API and return a Security Result or a Security Token.
|
|
44
|
+
|
|
45
|
+
### Prerequisites
|
|
46
|
+
|
|
47
|
+
Get required Public Keys at [https://dtect.security.dashboard.com](https://dtect.security.dashboard.com)
|
|
48
|
+
|
|
49
|
+
### Installation
|
|
50
|
+
|
|
51
|
+
Install package
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm install @dtect/security-sdk-js
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
or
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
yarn add @dtect/security-sdk-js
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
or CDN
|
|
64
|
+
|
|
65
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
66
|
+
|
|
67
|
+
<!-- USAGE EXAMPLES -->
|
|
68
|
+
|
|
69
|
+
## NPM Implementation
|
|
70
|
+
|
|
71
|
+
### 1. Start initialize security sdk by calling init function.
|
|
72
|
+
|
|
73
|
+
- Set `clientId` from your [dtect dashboard](https://dtect.security.dashboard.com/keys)
|
|
74
|
+
- Set `apiKey` from your [dtect dashboard](https://dtect.security.dashboard.com/keys)
|
|
75
|
+
|
|
76
|
+
```jsx
|
|
77
|
+
import dtect from "@dtect/security-sdk-js";
|
|
78
|
+
|
|
79
|
+
dtect.init({
|
|
80
|
+
clientId: "your-public-client-id-from-dashboard", // required
|
|
81
|
+
apiKey: "your-public-api-key-from-dashboard", // required
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
| Prop | Type | Description |
|
|
86
|
+
| :--------- | :------- | :----------------------------- |
|
|
87
|
+
| `clientId` | `string` | **Required**. public client id |
|
|
88
|
+
| `apiKey` | `string` | **Required**. public api key |
|
|
89
|
+
|
|
90
|
+
### 2. Use `getSecurityResult` or `getSecurityToken` function to check for visitor data
|
|
91
|
+
|
|
92
|
+
We recommend you to get `securityToken` from `getSecurityToken` then consult `securityResult`.
|
|
93
|
+
|
|
94
|
+
```jsx
|
|
95
|
+
import dtect from "@dtect/security-sdk-js";
|
|
96
|
+
|
|
97
|
+
// after init
|
|
98
|
+
dtect
|
|
99
|
+
.getSecurityToken({
|
|
100
|
+
projectId: "your-project-id-for-deduplication", // required
|
|
101
|
+
})
|
|
102
|
+
.then((token) => console.log(token));
|
|
103
|
+
|
|
104
|
+
dtect
|
|
105
|
+
.getSecurityResult({
|
|
106
|
+
projectId: "your-project-id-for-deduplication", // required
|
|
107
|
+
securitySettings: {
|
|
108
|
+
countriesAllowed: ["can"], // only visitors from Canada is allowed
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
.then((result) => console.log(result));
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
| Prop | Type | Description |
|
|
115
|
+
| :----------------- | :--------- | :-------------------------------------------------------------------------------------------------------------------------------------- |
|
|
116
|
+
| `projectId` | `string` | **Required**. A unique identifier for your project, study or survey. It allows our system to group visitor data and identify duplicates |
|
|
117
|
+
| `visitorId` | `string` | Id to identify the visitor that is being evaluated |
|
|
118
|
+
| `metaData` | `object` | Any additional information you want to add to each request |
|
|
119
|
+
| `securitySettings` | `object` | Configures security settings. Includes `countriesAllowed` |
|
|
120
|
+
| `countriesAllowed` | `string[]` | List of countries allowed for your project, survey, or study. |
|
|
121
|
+
|
|
122
|
+
## CDN Implementation
|
|
123
|
+
|
|
124
|
+
```html
|
|
125
|
+
<script>
|
|
126
|
+
const dtectPromise = import(`cdnurl`).then((dtect) =>
|
|
127
|
+
dtect.init({
|
|
128
|
+
clientId: "your-public-client-id-from-dashboard", // required
|
|
129
|
+
apiKey: "your-public-api-key-from-dashboard", // required
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// Use getSecurityToken
|
|
134
|
+
dtectPromise.then((dtect) =>
|
|
135
|
+
dtect
|
|
136
|
+
.getSecurityToken({
|
|
137
|
+
projectId: "your-project-id-for-deduplication", // required
|
|
138
|
+
})
|
|
139
|
+
.then((token) => console.log(token))
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
// or use getSecurityResult
|
|
143
|
+
dtectPromise.then((dtect) =>
|
|
144
|
+
dtect
|
|
145
|
+
.getSecurityResult({
|
|
146
|
+
projectId: "your-project-id-for-deduplication", // required
|
|
147
|
+
})
|
|
148
|
+
.then((securityResult) => console.log(securityResult))
|
|
149
|
+
);
|
|
150
|
+
</script>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Errors
|
|
154
|
+
|
|
155
|
+
Access the list of error enums from `SecurityAPIError`
|
|
156
|
+
|
|
157
|
+
### init()
|
|
158
|
+
|
|
159
|
+
You will see these errors on console
|
|
160
|
+
|
|
161
|
+
| Enum | Message | Description |
|
|
162
|
+
| :------------------------- | :---------------------------------------------- | :-------------------------------------------------------------------------------------- |
|
|
163
|
+
| `MISSING_CREDENTIALS` | Missing Public Client ID or Public API Key | Please provide valid Public Client ID and Public API Key when initializing our package. |
|
|
164
|
+
| `INVALID_CREDENTIALS` | Invalid Public Client ID or Public API Key | Ensure you are using valid Public Client ID and Public API Key. |
|
|
165
|
+
| `SDK_INIT_ERROR` | Internal Server Error during SDK Initialization | An unexpected error occurred on our servers during SDK initialization. |
|
|
166
|
+
| `DUPLICATE_INITIALIZATION` | Multiple SDK Initializations Detected | You should initialize our package only once. |
|
|
167
|
+
|
|
168
|
+
### getSecurityToken()/getSecurityResult()
|
|
169
|
+
|
|
170
|
+
| Error | Message | Description |
|
|
171
|
+
| :------------------------------ | :--------------------------------------- | :------------------------------------------------------------------------------------------------- |
|
|
172
|
+
| `NOT_INITIALIZED` | SDK Not Initialized | The SDK must be initialized before calling this function. |
|
|
173
|
+
| `INTERNAL_SERVER_ERROR` | Internal Server Error during API Request | An unexpected error occurred on our servers during the API request. Check server logs for details. |
|
|
174
|
+
| `FAILED_TO_GET_SECURITY_TOKEN` | Failed to Generate Security Token | An error occurred while generating the Security Token. |
|
|
175
|
+
| `FAILED_TO_GET_SECURITY_RESULT` | Failed to Retrieve Security Result | An error occurred while retrieving the Security Result. |
|
|
176
|
+
|
|
177
|
+
```jsx
|
|
178
|
+
import dtect, { SecurityAPIError } from "@dtect/security-sdk-js";
|
|
179
|
+
|
|
180
|
+
// after init
|
|
181
|
+
dtect
|
|
182
|
+
.getSecurityToken({
|
|
183
|
+
projectId: "your-project-id-for-deduplication", // required
|
|
184
|
+
})
|
|
185
|
+
.then((token) => console.log(token))
|
|
186
|
+
.catch((error) => {
|
|
187
|
+
switch (error.message) {
|
|
188
|
+
case SecurityAPIError.FAILED_TO_GET_SECURITY_TOKEN:
|
|
189
|
+
// log internally
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
<!-- LICENSE -->
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
199
|
+
|
|
200
|
+
<!-- CONTACT -->
|
|
201
|
+
|
|
202
|
+
## Contact
|
|
203
|
+
|
|
204
|
+
dtect - [Contact us](https://dtect.io/contact) - support@dtect.io
|
|
205
|
+
|
|
206
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var z=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var nt=(e,t)=>{for(var r in t)z(e,r,{get:t[r],enumerable:!0})},it=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of tt(t))!rt.call(e,i)&&i!==r&&z(e,i,{get:()=>t[i],enumerable:!(n=et(t,i))||n.enumerable});return e};var ot=e=>it(z({},"__esModule",{value:!0}),e);var Zt={};nt(Zt,{SecurityAPIError:()=>Xe,default:()=>Jt,getSecurityResult:()=>ye,getSecurityToken:()=>me,init:()=>ze});module.exports=ot(Zt);var S=function(){return S=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},S.apply(this,arguments)};function Ee(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function Re(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,s;n<i;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}function st(e,t){return function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}(e,t)?e[t]:void 0}function at(e,t,r,n){var i,s=document,u="securitypolicyviolation",o=function(y){var l=new URL(e,location.href),h=y.blockedURI;h!==l.href&&h!==l.protocol.slice(0,-1)&&h!==l.origin||(i=y,a())};s.addEventListener(u,o);var a=function(){return s.removeEventListener(u,o)};return n?.then(a,a),Promise.resolve().then(t).then(function(y){return a(),y},function(y){return new Promise(function(l){var h=new MessageChannel;h.port1.onmessage=function(){return l()},h.port2.postMessage(null)}).then(function(){if(a(),i)return r(i);throw y})})}var ut={default:"endpoint"},ct={default:"tlsEndpoint"},lt="Client timeout",ft="Network connection error",ht="Network request aborted",dt="Response cannot be parsed",J="Blocked by CSP",Z="The endpoint parameter is not a valid URL";function P(e){for(var t="",r=0;r<e.length;++r)if(r>0){var n=e[r].toLowerCase();n!==e[r]?t+=" ".concat(n):t+=e[r]}else t+=e[r].toUpperCase();return t}var pt=P("WrongRegion"),yt=P("SubscriptionNotActive"),mt=P("UnsupportedVersion"),Et=P("InstallationMethodRestricted"),Rt=P("HostnameRestricted"),Ot=P("IntegrationFailed"),H="API key required",Oe="API key not found",Te="API key expired",Tt="Request cannot be parsed",vt="Request failed",_t="Request failed to process",It="Too many requests, rate limit exceeded",gt="Not available for this origin",bt="Not available with restricted header",wt=H,Pt=Oe,At=Te,Dt="3.11.6",k="Failed to load the JS script of the agent",ee="9319";function Nt(e,t){var r,n,i,s,u,o,a,y=[],l=(r=function(f){var c=Re([],f,!0);return{current:function(){return c[0]},postpone:function(){var d=c.shift();d!==void 0&&c.push(d)},exclude:function(){c.shift()}}}(e),s=100,u=3e3,o=0,n=function(){return Math.random()*Math.min(u,s*Math.pow(2,o++))},i=new Set,[r.current(),function(f,c){var d,p=c instanceof Error?c.message:"";if(p===J||p===Z)r.exclude(),d=0;else if(p===ee)r.exclude();else if(p===k){var O=Date.now()-f.getTime()<50,T=r.current();T&&O&&!i.has(T)&&(i.add(T),d=0),r.postpone()}else r.postpone();var g=r.current();return g===void 0?void 0:[g,d??f.getTime()+n()-Date.now()]}]),h=l[0],_=l[1];if(h===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var I=function(f){var c=new Date,d=function(O){return y.push({url:f,startedAt:c,finishedAt:new Date,error:O})},p=t(f);return p.then(function(){return d()},d),p.catch(function(O){if(a!=null||(a=O),y.length>=5)throw a;var T=_(c,O);if(!T)throw a;var g,X=T[0],Ze=T[1];return(g=Ze,new Promise(function(He){return setTimeout(He,g)})).then(function(){return I(X)})})};return I(h).then(function(f){return[f,y]})}var ve="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",St=ve;function xt(e){var t;e.scriptUrlPattern;var r=e.token,n=e.apiKey,i=n===void 0?r:n,s=Ee(e,["scriptUrlPattern","token","apiKey"]),u=(t=st(e,"scriptUrlPattern"))!==null&&t!==void 0?t:ve,o=function(){var l=[],h=function(){l.push({time:new Date,state:document.visibilityState})},_=function(I,f,c,d){return I.addEventListener(f,c,d),function(){return I.removeEventListener(f,c,d)}}(document,"visibilitychange",h);return h(),[l,_]}(),a=o[0],y=o[1];return Promise.resolve().then(function(){if(!i||typeof i!="string")throw new Error(H);var l=function(h,_){return(Array.isArray(h)?h:[h]).map(function(I){return function(f,c){var d=encodeURIComponent;return f.replace(/<[^<>]+>/g,function(p){return p==="<version>"?"3":p==="<apiKey>"?d(c):p==="<loaderVersion>"?d(Dt):p})}(String(I),_)})}(u,i);return Nt(l,Mt)}).catch(function(l){throw y(),function(h){return h instanceof Error&&h.message===ee?new Error(k):h}(l)}).then(function(l){var h=l[0],_=l[1];return y(),h.load(S(S({},s),{ldi:{attempts:_,visibilityStates:a}}))})}function Mt(e){return at(e,function(){return function(t){return new Promise(function(r,n){if(function(o){if(URL.prototype)try{return new URL(o,location.href),!1}catch(a){if(a instanceof Error&&a.name==="TypeError")return!0;throw a}}(t))throw new Error(Z);var i=document.createElement("script"),s=function(){var o;return(o=i.parentNode)===null||o===void 0?void 0:o.removeChild(i)},u=document.head||document.getElementsByTagName("head")[0];i.onload=function(){s(),r()},i.onerror=function(){s(),n(new Error(k))},i.async=!0,i.src=t,u.appendChild(i)})}(e)},function(){throw new Error(J)}).then(Ft)}function Ft(){var e=window,t="__fpjs_p_l_b",r=e[t];if(function(n,i){var s,u=(s=Object.getOwnPropertyDescriptor)===null||s===void 0?void 0:s.call(Object,n,i);u?.configurable?delete n[i]:u&&!u.writable||(n[i]=void 0)}(e,t),typeof r?.load!="function")throw new Error(ee);return r}var _e={load:xt,defaultScriptUrlPattern:St,ERROR_SCRIPT_LOAD_FAIL:k,ERROR_API_KEY_EXPIRED:Te,ERROR_API_KEY_INVALID:Oe,ERROR_API_KEY_MISSING:H,ERROR_BAD_REQUEST_FORMAT:Tt,ERROR_BAD_RESPONSE_FORMAT:dt,ERROR_CLIENT_TIMEOUT:lt,ERROR_CSP_BLOCK:J,ERROR_FORBIDDEN_ENDPOINT:Rt,ERROR_FORBIDDEN_HEADER:bt,ERROR_FORBIDDEN_ORIGIN:gt,ERROR_GENERAL_SERVER_FAILURE:vt,ERROR_INSTALLATION_METHOD_RESTRICTED:Et,ERROR_INTEGRATION_FAILURE:Ot,ERROR_INVALID_ENDPOINT:Z,ERROR_NETWORK_ABORT:ht,ERROR_NETWORK_CONNECTION:ft,ERROR_RATE_LIMIT:It,ERROR_SERVER_TIMEOUT:_t,ERROR_SUBSCRIPTION_NOT_ACTIVE:yt,ERROR_TOKEN_EXPIRED:At,ERROR_TOKEN_INVALID:Pt,ERROR_TOKEN_MISSING:wt,ERROR_UNSUPPORTED_VERSION:mt,ERROR_WRONG_REGION:pt,defaultEndpoint:ut,defaultTlsEndpoint:ct};var E=[];for(let e=0;e<256;++e)E.push((e+256).toString(16).slice(1));function Ie(e,t=0){return(E[e[t+0]]+E[e[t+1]]+E[e[t+2]]+E[e[t+3]]+"-"+E[e[t+4]]+E[e[t+5]]+"-"+E[e[t+6]]+E[e[t+7]]+"-"+E[e[t+8]]+E[e[t+9]]+"-"+E[e[t+10]]+E[e[t+11]]+E[e[t+12]]+E[e[t+13]]+E[e[t+14]]+E[e[t+15]]).toLowerCase()}var te,Lt=new Uint8Array(16);function re(){if(!te){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");te=crypto.getRandomValues.bind(crypto)}return te(Lt)}var Ut=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ne={randomUUID:Ut};function qt(e,t,r){if(ne.randomUUID&&!t&&!e)return ne.randomUUID();e=e||{};let n=e.random??e.rng?.()??re();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Ie(n)}var K=qt;var jt={UNAUTHORIZED:"Unauthorized"},ge={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key"},be={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},we={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},Pe={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},Ae={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},R={...jt,...ge,...be,...we,...Pe,...Ae},De={...ge,...be,...we,...Pe,...Ae};var b=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var w=typeof window>"u"||"Deno"in globalThis;function v(){}function xe(e,t){return typeof e=="function"?e(t):e}function Me(e){return typeof e=="number"&&e>=0&&e!==1/0}function Fe(e,t){return Math.max(e+(t||0)-Date.now(),0)}function oe(e,t){return typeof e=="function"?e(t):e}function Le(e,t){return typeof e=="function"?e(t):e}function se(e,t){let{type:r="all",exact:n,fetchStatus:i,predicate:s,queryKey:u,stale:o}=e;if(u){if(n){if(t.queryHash!==x(u,t.options))return!1}else if(!D(t.queryKey,u))return!1}if(r!=="all"){let a=t.isActive();if(r==="active"&&!a||r==="inactive"&&a)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||i&&i!==t.state.fetchStatus||s&&!s(t))}function ae(e,t){let{exact:r,status:n,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(r){if(A(t.options.mutationKey)!==A(s))return!1}else if(!D(t.options.mutationKey,s))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function x(e,t){return(t?.queryKeyHashFn||A)(e)}function A(e){return JSON.stringify(e,(t,r)=>ie(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function D(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!D(e[r],t[r])):!1}function Ue(e,t){if(e===t)return e;let r=Ne(e)&&Ne(t);if(r||ie(e)&&ie(t)){let n=r?e:Object.keys(e),i=n.length,s=r?t:Object.keys(t),u=s.length,o=r?[]:{},a=0;for(let y=0;y<u;y++){let l=r?y:s[y];(!r&&n.includes(l)||r)&&e[l]===void 0&&t[l]===void 0?(o[l]=void 0,a++):(o[l]=Ue(e[l],t[l]),o[l]===e[l]&&e[l]!==void 0&&a++)}return i===u&&a===i?e:o}return t}function Ne(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ie(e){if(!Se(e))return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(!Se(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Se(e){return Object.prototype.toString.call(e)==="[object Object]"}function qe(e){return new Promise(t=>{setTimeout(t,e)})}function je(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?Ue(e,t):t}function ke(e,t,r=0){let n=[...e,t];return r&&n.length>r?n.slice(1):n}function Ke(e,t,r=0){let n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var M=Symbol();function Q(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===M?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var kt=class extends b{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!w&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},G=new kt;var Kt=class extends b{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!w&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},N=new Kt;function Qe(){let e,t,r=new Promise((i,s)=>{e=i,t=s});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),e(i)},r.reject=i=>{n({status:"rejected",reason:i}),t(i)},r}function Qt(e){return Math.min(1e3*2**e,3e4)}function ue(e){return(e??"online")==="online"?N.isOnline():!0}var Ge=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function B(e){return e instanceof Ge}function V(e){let t=!1,r=0,n=!1,i,s=Qe(),u=c=>{n||(_(new Ge(c)),e.abort?.())},o=()=>{t=!0},a=()=>{t=!1},y=()=>G.isFocused()&&(e.networkMode==="always"||N.isOnline())&&e.canRun(),l=()=>ue(e.networkMode)&&e.canRun(),h=c=>{n||(n=!0,e.onSuccess?.(c),i?.(),s.resolve(c))},_=c=>{n||(n=!0,e.onError?.(c),i?.(),s.reject(c))},I=()=>new Promise(c=>{i=d=>{(n||y())&&c(d)},e.onPause?.()}).then(()=>{i=void 0,n||e.onContinue?.()}),f=()=>{if(n)return;let c,d=r===0?e.initialPromise:void 0;try{c=d??e.fn()}catch(p){c=Promise.reject(p)}Promise.resolve(c).then(h).catch(p=>{if(n)return;let O=e.retry??(w?0:3),T=e.retryDelay??Qt,g=typeof T=="function"?T(r,p):T,X=O===!0||typeof O=="number"&&r<O||typeof O=="function"&&O(r,p);if(t||!X){_(p);return}r++,e.onFail?.(r,p),qe(g).then(()=>y()?void 0:I()).then(()=>{t?_(p):f()})})};return{promise:s,cancel:u,continue:()=>(i?.(),s),cancelRetry:o,continueRetry:a,canStart:l,start:()=>(l()?f():I().then(f),s)}}function Gt(){let e=[],t=0,r=o=>{o()},n=o=>{o()},i=o=>setTimeout(o,0),s=o=>{t?e.push(o):i(()=>{r(o)})},u=()=>{let o=e;e=[],o.length&&i(()=>{n(()=>{o.forEach(a=>{r(a)})})})};return{batch:o=>{let a;t++;try{a=o()}finally{t--,t||u()}return a},batchCalls:o=>(...a)=>{s(()=>{o(...a)})},schedule:s,setNotifyFunction:o=>{r=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{i=o}}}var m=Gt();var C=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Me(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(w?1/0:5*60*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}};var Be=class extends C{#e;#t;#r;#n;#s;#o;constructor(e){super(),this.#o=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Vt(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){let r=je(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(v).catch(v):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Le(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===M||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Fe(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#o?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){let o=this.observers.find(a=>a.options.queryFn);o&&this.setOptions(o.options)}let r=new AbortController,n=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,r.signal)})},i=()=>{let o=Q(this.options,t),a={queryKey:this.queryKey,meta:this.meta};return n(a),this.#o=!1,this.options.persister?this.options.persister(o,a,this):o(a)},s={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};n(s),this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#i({type:"fetch",meta:s.fetchOptions?.meta});let u=o=>{B(o)&&o.silent||this.#i({type:"error",error:o}),B(o)||(this.#r.config.onError?.(o,this),this.#r.config.onSettled?.(this.state.data,o,this)),this.scheduleGc()};return this.#n=V({initialPromise:t?.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:o=>{if(o===void 0){u(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(o)}catch(a){u(a);return}this.#r.config.onSuccess?.(o,this),this.#r.config.onSettled?.(o,this.state.error,this),this.scheduleGc()},onError:u,onFail:(o,a)=>{this.#i({type:"failed",failureCount:o,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0}),this.#n.start()}#i(e){let t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Bt(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let n=e.error;return B(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),m.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Bt(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ue(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Vt(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var F=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let n=t.queryKey,i=t.queryHash??x(n,t),s=this.get(i);return s||(s=new Be({cache:this,queryKey:n,queryHash:i,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(s)),s}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){m.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(r=>se(t,r))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(r=>se(e,r)):t}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){m.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){m.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var Ve=class extends C{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||Ct(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=V({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,i)=>{this.#n({type:"failed",failureCount:n,error:i})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let t=this.state.status==="pending",r=!this.#r.canStart();try{if(!t){this.#n({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let i=await this.options.onMutate?.(e);i!==this.state.context&&this.#n({type:"pending",context:i,variables:e,isPaused:r})}let n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#n({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#n({type:"error",error:n})}}finally{this.#t.runNext(this)}}#n(e){let t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),m.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function Ct(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var L=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){let n=new Ve({mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#e.add(e);let t=Y(e);if(typeof t=="string"){let r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=Y(e);if(typeof t=="string"){let r=this.#t.get(t);if(r)if(r.length>1){let n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=Y(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(i=>i.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=Y(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){m.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(r=>ae(t,r))}findAll(e={}){return this.getAll().filter(t=>ae(e,t))}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return m.batch(()=>Promise.all(e.map(t=>t.continue().catch(v))))}};function Y(e){return e.options.scope?.id}function ce(e){return{onFetch:(t,r)=>{let n=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],u=t.state.data?.pageParams||[],o={pages:[],pageParams:[]},a=0,y=async()=>{let l=!1,h=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},_=Q(t.options,t.fetchOptions),I=async(f,c,d)=>{if(l)return Promise.reject();if(c==null&&f.pages.length)return Promise.resolve(f);let p={queryKey:t.queryKey,pageParam:c,direction:d?"backward":"forward",meta:t.options.meta};h(p);let O=await _(p),{maxPages:T}=t.options,g=d?Ke:ke;return{pages:g(f.pages,O,T),pageParams:g(f.pageParams,c,T)}};if(i&&s.length){let f=i==="backward",c=f?Yt:Ce,d={pages:s,pageParams:u},p=c(n,d);o=await I(d,p,f)}else{let f=e??s.length;do{let c=a===0?u[0]??n.initialPageParam:Ce(n,o);if(a>0&&c==null)break;o=await I(o,c),a++}while(a<f)}return o};t.options.persister?t.fetchFn=()=>t.options.persister?.(y,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=y}}}function Ce(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Yt(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var le=class{#e;#t;#r;#n;#s;#o;#i;#a;constructor(e={}){this.#e=e.queryCache||new F,this.#t=e.mutationCache||new L,this.#r=e.defaultOptions||{},this.#n=new Map,this.#s=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=G.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=N.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(oe(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{let n=r.data;return[t,n]})}setQueryData(e,t,r){let n=this.defaultQueryOptions({queryKey:e}),s=this.#e.get(n.queryHash)?.state.data,u=xe(t,s);if(u!==void 0)return this.#e.build(this,n).setData(u,{...r,manual:!0})}setQueriesData(e,t,r){return m.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;m.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){let r=this.#e,n={type:"active",...e};return m.batch(()=>(r.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){let r={revert:!0,...t},n=m.batch(()=>this.#e.findAll(e).map(i=>i.cancel(r)));return Promise.all(n).then(v).catch(v)}invalidateQueries(e,t={}){return m.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();let r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0},n=m.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let s=i.fetch(void 0,r);return r.throwOnError||(s=s.catch(v)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(n).then(v)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(oe(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(v).catch(v)}fetchInfiniteQuery(e){return e.behavior=ce(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(v).catch(v)}ensureInfiniteQueryData(e){return e.behavior=ce(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return N.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#n.set(A(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#n.values()],r={};return t.forEach(n=>{D(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#s.set(A(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#s.values()],r={};return t.forEach(n=>{D(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=x(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===M&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var Wt=new le({defaultOptions:{queries:{staleTime:3e4}},queryCache:new F({onError:(e,t)=>{}}),mutationCache:new L}),Ye=Wt;var $t=(e,t={})=>({"Content-Type":"application/json",...e?.accessToken&&{Authorization:`Bearer ${e?.accessToken}`},...t}),Xt=async(e,t)=>{if(!e.ok){let r=await e.text();throw new Error(r)}return t==="file"?e.blob():t==="json"?e.json():t==="text"?e.text():null},We=async({url:e,auth:t,body:r,method:n="GET",headers:i={},responseType:s="json"})=>{let u={method:n,headers:$t(t,i),...r?{body:r instanceof FormData?r:JSON.stringify(r)}:{}},o=await fetch(e,u);return Xt(o,s)},$e=e=>We({...e,method:"GET"}),fe=e=>We({...e,method:"POST"});var he,de="https://api.dtect.io/security",q="",j="",W,U={isLoading:!1},Xe=De;function $(){return!!(document.querySelector("#dtect-h-captcha")&&he)}function pe(){return!!(q&&j)}async function zt({automationKey:e,behaviorKey:t}){let r=document.querySelector("head"),n=document.createElement("script");if(n.setAttribute("src","https://js.hcaptcha.com/1/api.js"),n.setAttribute("async","true"),n.setAttribute("defer","true"),r?.append(n),document.querySelector("body")?.insertAdjacentHTML("beforeend",`<div id="dtect-h-captcha" class="h-captcha" data-sitekey=${e} data-size="invisible"></h-captcha>`),!document.querySelector("#dtect-h-captcha"))throw new Error(R.SDK_INIT_ERROR);let u=await _e.load({apiKey:t});if(u)he=u;else throw new Error(R.SDK_INIT_ERROR)}async function ze(e){if(!e?.clientId||!e?.apiKey)throw new Error(R.MISSING_CREDENTIALS);let{clientId:t,apiKey:r,endpoint:n="https://api.dtect.io/security"}=e;if(de=n,U.isLoading){if($())return W;throw new Error(R.DUPLICATE_INITIALIZATION)}if(q=t,j=r,U={...U,isLoading:!0},!pe())throw new Error(R.MISSING_CREDENTIALS);if($())return W;try{let i=await Ye.fetchQuery({queryKey:["getKeys",t,r],queryFn:()=>$e({url:`${n}/client/get-config`,headers:{"client-id":q,"x-api-key":j}})});if(i?.automationKey&&i?.behaviorKey)return zt({...i}).then(()=>({getSecurityResult:ye,getSecurityToken:me,SecurityAPIError:Xe})).catch(s=>{throw new Error(s.message)});throw new Error}catch(i){throw i instanceof Error&&i?.message?.includes(R.UNAUTHORIZED)?new Error(R.INVALID_CREDENTIALS):new Error(R.SDK_INIT_ERROR)}finally{U={...U,isLoading:!1}}}async function Je(){let e=await window?.hcaptcha?.execute({async:!0}),t=await he?.get();if(e?.response&&t?.sealedResult&&t?.requestId)return{behaviorRequestId:t.requestId,behaviorToken:t.sealedResult,automationToken:e.response};throw new Error(R.INTERNAL_SERVER_ERROR)}async function ye(e){if(!$())throw new Error(R.NOT_INITIALIZED);if(!pe())throw new Error(R.MISSING_CREDENTIALS);try{let t=await Je();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,visitorId:e.visitorId||K(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await fe({url:`${de}/client/verify/get-results`,body:{...r},headers:{"client-id":q,"x-api-key":j}});if(n?.results?.dtectScore)return n}throw new Error}catch{throw new Error(R.FAILED_TO_GET_SECURITY_RESULT)}}async function me(e){if(!$())throw new Error(R.NOT_INITIALIZED);if(!pe())throw new Error(R.MISSING_CREDENTIALS);try{let t=await Je();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,visitorId:e.visitorId||K(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await fe({url:`${de}/client/verify/get-token`,body:{...r},headers:{"client-id":q,"x-api-key":j}});if(n?.token)return n}throw new Error}catch{throw new Error(R.FAILED_TO_GET_SECURITY_TOKEN)}}W={init:ze,getSecurityResult:ye,getSecurityToken:me};var Jt=W;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var S=function(){return S=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},S.apply(this,arguments)};function pe(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function ye(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,s;n<i;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}function Je(e,t){return function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}(e,t)?e[t]:void 0}function Ze(e,t,r,n){var i,s=document,u="securitypolicyviolation",o=function(y){var l=new URL(e,location.href),h=y.blockedURI;h!==l.href&&h!==l.protocol.slice(0,-1)&&h!==l.origin||(i=y,a())};s.addEventListener(u,o);var a=function(){return s.removeEventListener(u,o)};return n?.then(a,a),Promise.resolve().then(t).then(function(y){return a(),y},function(y){return new Promise(function(l){var h=new MessageChannel;h.port1.onmessage=function(){return l()},h.port2.postMessage(null)}).then(function(){if(a(),i)return r(i);throw y})})}var He={default:"endpoint"},et={default:"tlsEndpoint"},tt="Client timeout",rt="Network connection error",nt="Network request aborted",it="Response cannot be parsed",z="Blocked by CSP",J="The endpoint parameter is not a valid URL";function P(e){for(var t="",r=0;r<e.length;++r)if(r>0){var n=e[r].toLowerCase();n!==e[r]?t+=" ".concat(n):t+=e[r]}else t+=e[r].toUpperCase();return t}var ot=P("WrongRegion"),st=P("SubscriptionNotActive"),at=P("UnsupportedVersion"),ut=P("InstallationMethodRestricted"),ct=P("HostnameRestricted"),lt=P("IntegrationFailed"),Z="API key required",me="API key not found",Ee="API key expired",ft="Request cannot be parsed",ht="Request failed",dt="Request failed to process",pt="Too many requests, rate limit exceeded",yt="Not available for this origin",mt="Not available with restricted header",Et=Z,Rt=me,Ot=Ee,Tt="3.11.6",k="Failed to load the JS script of the agent",H="9319";function vt(e,t){var r,n,i,s,u,o,a,y=[],l=(r=function(f){var c=ye([],f,!0);return{current:function(){return c[0]},postpone:function(){var d=c.shift();d!==void 0&&c.push(d)},exclude:function(){c.shift()}}}(e),s=100,u=3e3,o=0,n=function(){return Math.random()*Math.min(u,s*Math.pow(2,o++))},i=new Set,[r.current(),function(f,c){var d,p=c instanceof Error?c.message:"";if(p===z||p===J)r.exclude(),d=0;else if(p===H)r.exclude();else if(p===k){var O=Date.now()-f.getTime()<50,T=r.current();T&&O&&!i.has(T)&&(i.add(T),d=0),r.postpone()}else r.postpone();var g=r.current();return g===void 0?void 0:[g,d??f.getTime()+n()-Date.now()]}]),h=l[0],_=l[1];if(h===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var I=function(f){var c=new Date,d=function(O){return y.push({url:f,startedAt:c,finishedAt:new Date,error:O})},p=t(f);return p.then(function(){return d()},d),p.catch(function(O){if(a!=null||(a=O),y.length>=5)throw a;var T=_(c,O);if(!T)throw a;var g,X=T[0],Xe=T[1];return(g=Xe,new Promise(function(ze){return setTimeout(ze,g)})).then(function(){return I(X)})})};return I(h).then(function(f){return[f,y]})}var Re="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",_t=Re;function It(e){var t;e.scriptUrlPattern;var r=e.token,n=e.apiKey,i=n===void 0?r:n,s=pe(e,["scriptUrlPattern","token","apiKey"]),u=(t=Je(e,"scriptUrlPattern"))!==null&&t!==void 0?t:Re,o=function(){var l=[],h=function(){l.push({time:new Date,state:document.visibilityState})},_=function(I,f,c,d){return I.addEventListener(f,c,d),function(){return I.removeEventListener(f,c,d)}}(document,"visibilitychange",h);return h(),[l,_]}(),a=o[0],y=o[1];return Promise.resolve().then(function(){if(!i||typeof i!="string")throw new Error(Z);var l=function(h,_){return(Array.isArray(h)?h:[h]).map(function(I){return function(f,c){var d=encodeURIComponent;return f.replace(/<[^<>]+>/g,function(p){return p==="<version>"?"3":p==="<apiKey>"?d(c):p==="<loaderVersion>"?d(Tt):p})}(String(I),_)})}(u,i);return vt(l,gt)}).catch(function(l){throw y(),function(h){return h instanceof Error&&h.message===H?new Error(k):h}(l)}).then(function(l){var h=l[0],_=l[1];return y(),h.load(S(S({},s),{ldi:{attempts:_,visibilityStates:a}}))})}function gt(e){return Ze(e,function(){return function(t){return new Promise(function(r,n){if(function(o){if(URL.prototype)try{return new URL(o,location.href),!1}catch(a){if(a instanceof Error&&a.name==="TypeError")return!0;throw a}}(t))throw new Error(J);var i=document.createElement("script"),s=function(){var o;return(o=i.parentNode)===null||o===void 0?void 0:o.removeChild(i)},u=document.head||document.getElementsByTagName("head")[0];i.onload=function(){s(),r()},i.onerror=function(){s(),n(new Error(k))},i.async=!0,i.src=t,u.appendChild(i)})}(e)},function(){throw new Error(z)}).then(bt)}function bt(){var e=window,t="__fpjs_p_l_b",r=e[t];if(function(n,i){var s,u=(s=Object.getOwnPropertyDescriptor)===null||s===void 0?void 0:s.call(Object,n,i);u?.configurable?delete n[i]:u&&!u.writable||(n[i]=void 0)}(e,t),typeof r?.load!="function")throw new Error(H);return r}var Oe={load:It,defaultScriptUrlPattern:_t,ERROR_SCRIPT_LOAD_FAIL:k,ERROR_API_KEY_EXPIRED:Ee,ERROR_API_KEY_INVALID:me,ERROR_API_KEY_MISSING:Z,ERROR_BAD_REQUEST_FORMAT:ft,ERROR_BAD_RESPONSE_FORMAT:it,ERROR_CLIENT_TIMEOUT:tt,ERROR_CSP_BLOCK:z,ERROR_FORBIDDEN_ENDPOINT:ct,ERROR_FORBIDDEN_HEADER:mt,ERROR_FORBIDDEN_ORIGIN:yt,ERROR_GENERAL_SERVER_FAILURE:ht,ERROR_INSTALLATION_METHOD_RESTRICTED:ut,ERROR_INTEGRATION_FAILURE:lt,ERROR_INVALID_ENDPOINT:J,ERROR_NETWORK_ABORT:nt,ERROR_NETWORK_CONNECTION:rt,ERROR_RATE_LIMIT:pt,ERROR_SERVER_TIMEOUT:dt,ERROR_SUBSCRIPTION_NOT_ACTIVE:st,ERROR_TOKEN_EXPIRED:Ot,ERROR_TOKEN_INVALID:Rt,ERROR_TOKEN_MISSING:Et,ERROR_UNSUPPORTED_VERSION:at,ERROR_WRONG_REGION:ot,defaultEndpoint:He,defaultTlsEndpoint:et};var E=[];for(let e=0;e<256;++e)E.push((e+256).toString(16).slice(1));function Te(e,t=0){return(E[e[t+0]]+E[e[t+1]]+E[e[t+2]]+E[e[t+3]]+"-"+E[e[t+4]]+E[e[t+5]]+"-"+E[e[t+6]]+E[e[t+7]]+"-"+E[e[t+8]]+E[e[t+9]]+"-"+E[e[t+10]]+E[e[t+11]]+E[e[t+12]]+E[e[t+13]]+E[e[t+14]]+E[e[t+15]]).toLowerCase()}var ee,wt=new Uint8Array(16);function te(){if(!ee){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ee=crypto.getRandomValues.bind(crypto)}return ee(wt)}var Pt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),re={randomUUID:Pt};function At(e,t,r){if(re.randomUUID&&!t&&!e)return re.randomUUID();e=e||{};let n=e.random??e.rng?.()??te();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Te(n)}var K=At;var Dt={UNAUTHORIZED:"Unauthorized"},ve={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key"},_e={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},Ie={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},ge={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},be={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},R={...Dt,...ve,..._e,...Ie,...ge,...be},we={...ve,..._e,...Ie,...ge,...be};var b=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var w=typeof window>"u"||"Deno"in globalThis;function v(){}function De(e,t){return typeof e=="function"?e(t):e}function Ne(e){return typeof e=="number"&&e>=0&&e!==1/0}function Se(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ie(e,t){return typeof e=="function"?e(t):e}function xe(e,t){return typeof e=="function"?e(t):e}function oe(e,t){let{type:r="all",exact:n,fetchStatus:i,predicate:s,queryKey:u,stale:o}=e;if(u){if(n){if(t.queryHash!==x(u,t.options))return!1}else if(!D(t.queryKey,u))return!1}if(r!=="all"){let a=t.isActive();if(r==="active"&&!a||r==="inactive"&&a)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||i&&i!==t.state.fetchStatus||s&&!s(t))}function se(e,t){let{exact:r,status:n,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(r){if(A(t.options.mutationKey)!==A(s))return!1}else if(!D(t.options.mutationKey,s))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function x(e,t){return(t?.queryKeyHashFn||A)(e)}function A(e){return JSON.stringify(e,(t,r)=>ne(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function D(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!D(e[r],t[r])):!1}function Me(e,t){if(e===t)return e;let r=Pe(e)&&Pe(t);if(r||ne(e)&&ne(t)){let n=r?e:Object.keys(e),i=n.length,s=r?t:Object.keys(t),u=s.length,o=r?[]:{},a=0;for(let y=0;y<u;y++){let l=r?y:s[y];(!r&&n.includes(l)||r)&&e[l]===void 0&&t[l]===void 0?(o[l]=void 0,a++):(o[l]=Me(e[l],t[l]),o[l]===e[l]&&e[l]!==void 0&&a++)}return i===u&&a===i?e:o}return t}function Pe(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ne(e){if(!Ae(e))return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(!Ae(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Ae(e){return Object.prototype.toString.call(e)==="[object Object]"}function Fe(e){return new Promise(t=>{setTimeout(t,e)})}function Le(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?Me(e,t):t}function Ue(e,t,r=0){let n=[...e,t];return r&&n.length>r?n.slice(1):n}function qe(e,t,r=0){let n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var M=Symbol();function Q(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===M?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Nt=class extends b{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!w&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},G=new Nt;var St=class extends b{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!w&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},N=new St;function je(){let e,t,r=new Promise((i,s)=>{e=i,t=s});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),e(i)},r.reject=i=>{n({status:"rejected",reason:i}),t(i)},r}function xt(e){return Math.min(1e3*2**e,3e4)}function ae(e){return(e??"online")==="online"?N.isOnline():!0}var ke=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function B(e){return e instanceof ke}function V(e){let t=!1,r=0,n=!1,i,s=je(),u=c=>{n||(_(new ke(c)),e.abort?.())},o=()=>{t=!0},a=()=>{t=!1},y=()=>G.isFocused()&&(e.networkMode==="always"||N.isOnline())&&e.canRun(),l=()=>ae(e.networkMode)&&e.canRun(),h=c=>{n||(n=!0,e.onSuccess?.(c),i?.(),s.resolve(c))},_=c=>{n||(n=!0,e.onError?.(c),i?.(),s.reject(c))},I=()=>new Promise(c=>{i=d=>{(n||y())&&c(d)},e.onPause?.()}).then(()=>{i=void 0,n||e.onContinue?.()}),f=()=>{if(n)return;let c,d=r===0?e.initialPromise:void 0;try{c=d??e.fn()}catch(p){c=Promise.reject(p)}Promise.resolve(c).then(h).catch(p=>{if(n)return;let O=e.retry??(w?0:3),T=e.retryDelay??xt,g=typeof T=="function"?T(r,p):T,X=O===!0||typeof O=="number"&&r<O||typeof O=="function"&&O(r,p);if(t||!X){_(p);return}r++,e.onFail?.(r,p),Fe(g).then(()=>y()?void 0:I()).then(()=>{t?_(p):f()})})};return{promise:s,cancel:u,continue:()=>(i?.(),s),cancelRetry:o,continueRetry:a,canStart:l,start:()=>(l()?f():I().then(f),s)}}function Mt(){let e=[],t=0,r=o=>{o()},n=o=>{o()},i=o=>setTimeout(o,0),s=o=>{t?e.push(o):i(()=>{r(o)})},u=()=>{let o=e;e=[],o.length&&i(()=>{n(()=>{o.forEach(a=>{r(a)})})})};return{batch:o=>{let a;t++;try{a=o()}finally{t--,t||u()}return a},batchCalls:o=>(...a)=>{s(()=>{o(...a)})},schedule:s,setNotifyFunction:o=>{r=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{i=o}}}var m=Mt();var C=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ne(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(w?1/0:5*60*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}};var Ke=class extends C{#e;#t;#r;#n;#s;#o;constructor(e){super(),this.#o=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Lt(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){let r=Le(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(v).catch(v):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>xe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===M||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Se(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#o?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){let o=this.observers.find(a=>a.options.queryFn);o&&this.setOptions(o.options)}let r=new AbortController,n=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,r.signal)})},i=()=>{let o=Q(this.options,t),a={queryKey:this.queryKey,meta:this.meta};return n(a),this.#o=!1,this.options.persister?this.options.persister(o,a,this):o(a)},s={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};n(s),this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#i({type:"fetch",meta:s.fetchOptions?.meta});let u=o=>{B(o)&&o.silent||this.#i({type:"error",error:o}),B(o)||(this.#r.config.onError?.(o,this),this.#r.config.onSettled?.(this.state.data,o,this)),this.scheduleGc()};return this.#n=V({initialPromise:t?.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:o=>{if(o===void 0){u(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(o)}catch(a){u(a);return}this.#r.config.onSuccess?.(o,this),this.#r.config.onSettled?.(o,this.state.error,this),this.scheduleGc()},onError:u,onFail:(o,a)=>{this.#i({type:"failed",failureCount:o,error:a})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0}),this.#n.start()}#i(e){let t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ft(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":let n=e.error;return B(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),m.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Ft(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ae(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Lt(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var F=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let n=t.queryKey,i=t.queryHash??x(n,t),s=this.get(i);return s||(s=new Ke({cache:this,queryKey:n,queryHash:i,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(s)),s}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){m.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(r=>oe(t,r))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(r=>oe(e,r)):t}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){m.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){m.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}};var Qe=class extends C{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||Ut(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=V({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,i)=>{this.#n({type:"failed",failureCount:n,error:i})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let t=this.state.status==="pending",r=!this.#r.canStart();try{if(!t){this.#n({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let i=await this.options.onMutate?.(e);i!==this.state.context&&this.#n({type:"pending",context:i,variables:e,isPaused:r})}let n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#n({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#n({type:"error",error:n})}}finally{this.#t.runNext(this)}}#n(e){let t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),m.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function Ut(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var L=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){let n=new Qe({mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#e.add(e);let t=Y(e);if(typeof t=="string"){let r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=Y(e);if(typeof t=="string"){let r=this.#t.get(t);if(r)if(r.length>1){let n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=Y(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(i=>i.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=Y(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){m.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(r=>se(t,r))}findAll(e={}){return this.getAll().filter(t=>se(e,t))}notify(e){m.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return m.batch(()=>Promise.all(e.map(t=>t.continue().catch(v))))}};function Y(e){return e.options.scope?.id}function ue(e){return{onFetch:(t,r)=>{let n=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],u=t.state.data?.pageParams||[],o={pages:[],pageParams:[]},a=0,y=async()=>{let l=!1,h=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},_=Q(t.options,t.fetchOptions),I=async(f,c,d)=>{if(l)return Promise.reject();if(c==null&&f.pages.length)return Promise.resolve(f);let p={queryKey:t.queryKey,pageParam:c,direction:d?"backward":"forward",meta:t.options.meta};h(p);let O=await _(p),{maxPages:T}=t.options,g=d?qe:Ue;return{pages:g(f.pages,O,T),pageParams:g(f.pageParams,c,T)}};if(i&&s.length){let f=i==="backward",c=f?qt:Ge,d={pages:s,pageParams:u},p=c(n,d);o=await I(d,p,f)}else{let f=e??s.length;do{let c=a===0?u[0]??n.initialPageParam:Ge(n,o);if(a>0&&c==null)break;o=await I(o,c),a++}while(a<f)}return o};t.options.persister?t.fetchFn=()=>t.options.persister?.(y,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=y}}}function Ge(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function qt(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var ce=class{#e;#t;#r;#n;#s;#o;#i;#a;constructor(e={}){this.#e=e.queryCache||new F,this.#t=e.mutationCache||new L,this.#r=e.defaultOptions||{},this.#n=new Map,this.#s=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=G.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=N.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(ie(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{let n=r.data;return[t,n]})}setQueryData(e,t,r){let n=this.defaultQueryOptions({queryKey:e}),s=this.#e.get(n.queryHash)?.state.data,u=De(t,s);if(u!==void 0)return this.#e.build(this,n).setData(u,{...r,manual:!0})}setQueriesData(e,t,r){return m.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;m.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){let r=this.#e,n={type:"active",...e};return m.batch(()=>(r.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){let r={revert:!0,...t},n=m.batch(()=>this.#e.findAll(e).map(i=>i.cancel(r)));return Promise.all(n).then(v).catch(v)}invalidateQueries(e,t={}){return m.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();let r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0},n=m.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let s=i.fetch(void 0,r);return r.throwOnError||(s=s.catch(v)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(n).then(v)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(ie(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(v).catch(v)}fetchInfiniteQuery(e){return e.behavior=ue(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(v).catch(v)}ensureInfiniteQueryData(e){return e.behavior=ue(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return N.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#n.set(A(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#n.values()],r={};return t.forEach(n=>{D(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#s.set(A(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#s.values()],r={};return t.forEach(n=>{D(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=x(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===M&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var jt=new ce({defaultOptions:{queries:{staleTime:3e4}},queryCache:new F({onError:(e,t)=>{}}),mutationCache:new L}),Be=jt;var kt=(e,t={})=>({"Content-Type":"application/json",...e?.accessToken&&{Authorization:`Bearer ${e?.accessToken}`},...t}),Kt=async(e,t)=>{if(!e.ok){let r=await e.text();throw new Error(r)}return t==="file"?e.blob():t==="json"?e.json():t==="text"?e.text():null},Ve=async({url:e,auth:t,body:r,method:n="GET",headers:i={},responseType:s="json"})=>{let u={method:n,headers:kt(t,i),...r?{body:r instanceof FormData?r:JSON.stringify(r)}:{}},o=await fetch(e,u);return Kt(o,s)},Ce=e=>Ve({...e,method:"GET"}),le=e=>Ve({...e,method:"POST"});var fe,he="https://api.dtect.io/security",q="",j="",W,U={isLoading:!1},Qt=we;function $(){return!!(document.querySelector("#dtect-h-captcha")&&fe)}function de(){return!!(q&&j)}async function Gt({automationKey:e,behaviorKey:t}){let r=document.querySelector("head"),n=document.createElement("script");if(n.setAttribute("src","https://js.hcaptcha.com/1/api.js"),n.setAttribute("async","true"),n.setAttribute("defer","true"),r?.append(n),document.querySelector("body")?.insertAdjacentHTML("beforeend",`<div id="dtect-h-captcha" class="h-captcha" data-sitekey=${e} data-size="invisible"></h-captcha>`),!document.querySelector("#dtect-h-captcha"))throw new Error(R.SDK_INIT_ERROR);let u=await Oe.load({apiKey:t});if(u)fe=u;else throw new Error(R.SDK_INIT_ERROR)}async function Bt(e){if(!e?.clientId||!e?.apiKey)throw new Error(R.MISSING_CREDENTIALS);let{clientId:t,apiKey:r,endpoint:n="https://api.dtect.io/security"}=e;if(he=n,U.isLoading){if($())return W;throw new Error(R.DUPLICATE_INITIALIZATION)}if(q=t,j=r,U={...U,isLoading:!0},!de())throw new Error(R.MISSING_CREDENTIALS);if($())return W;try{let i=await Be.fetchQuery({queryKey:["getKeys",t,r],queryFn:()=>Ce({url:`${n}/client/get-config`,headers:{"client-id":q,"x-api-key":j}})});if(i?.automationKey&&i?.behaviorKey)return Gt({...i}).then(()=>({getSecurityResult:We,getSecurityToken:$e,SecurityAPIError:Qt})).catch(s=>{throw new Error(s.message)});throw new Error}catch(i){throw i instanceof Error&&i?.message?.includes(R.UNAUTHORIZED)?new Error(R.INVALID_CREDENTIALS):new Error(R.SDK_INIT_ERROR)}finally{U={...U,isLoading:!1}}}async function Ye(){let e=await window?.hcaptcha?.execute({async:!0}),t=await fe?.get();if(e?.response&&t?.sealedResult&&t?.requestId)return{behaviorRequestId:t.requestId,behaviorToken:t.sealedResult,automationToken:e.response};throw new Error(R.INTERNAL_SERVER_ERROR)}async function We(e){if(!$())throw new Error(R.NOT_INITIALIZED);if(!de())throw new Error(R.MISSING_CREDENTIALS);try{let t=await Ye();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,visitorId:e.visitorId||K(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await le({url:`${he}/client/verify/get-results`,body:{...r},headers:{"client-id":q,"x-api-key":j}});if(n?.results?.dtectScore)return n}throw new Error}catch{throw new Error(R.FAILED_TO_GET_SECURITY_RESULT)}}async function $e(e){if(!$())throw new Error(R.NOT_INITIALIZED);if(!de())throw new Error(R.MISSING_CREDENTIALS);try{let t=await Ye();if(t?.behaviorToken&&t?.behaviorRequestId&&t?.behaviorToken){let r={...e,visitorId:e.visitorId||K(),visitorData:{behaviorToken:t.behaviorToken,automationToken:t.automationToken,behaviorRequestId:t.behaviorRequestId,entryLink:window?.location?.href}},n=await le({url:`${he}/client/verify/get-token`,body:{...r},headers:{"client-id":q,"x-api-key":j}});if(n?.token)return n}throw new Error}catch{throw new Error(R.FAILED_TO_GET_SECURITY_TOKEN)}}W={init:Bt,getSecurityResult:We,getSecurityToken:$e};var Qn=W;export{Qt as SecurityAPIError,Qn as default,We as getSecurityResult,$e as getSecurityToken,Bt as init};
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dtect/security-sdk-js",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/index.mjs",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsup --dts",
|
|
9
|
+
"ts:check": "tsc --noEmit"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@fingerprintjs/fingerprintjs-pro": "^3.11.6",
|
|
13
|
+
"@tanstack/query-core": "^5.64.2",
|
|
14
|
+
"uuid": "^11.0.5"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@eslint/js": "^9.17.0",
|
|
18
|
+
"@hcaptcha/types": "^1.0.4",
|
|
19
|
+
"@types/uuid": "^10.0.0",
|
|
20
|
+
"eslint": "^9.17.0",
|
|
21
|
+
"tsup": "^8.3.5",
|
|
22
|
+
"typescript": "^5.7.2",
|
|
23
|
+
"typescript-eslint": "^8.19.0"
|
|
24
|
+
},
|
|
25
|
+
"author": "dtect",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"description": "",
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"exports": {
|
|
32
|
+
".": "./src/index.ts"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/index.mjs"
|
|
36
|
+
]
|
|
37
|
+
}
|