@dtect/security-sdk-react 0.0.6 → 0.0.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/README.md CHANGED
@@ -6,32 +6,22 @@ Security API SDK for React by dtect.
6
6
  <details>
7
7
  <summary>Table of Contents</summary>
8
8
  <ol>
9
- <li>
10
- <a href="#about-the-project">About The Project</a>
11
- </li>
9
+
12
10
  <li>
13
11
  <a href="#getting-started">Getting Started</a>
14
12
  <ul>
15
- <li><a href="#prerequisites">Prerequisites</a></li>
16
13
  <li><a href="#installation">Installation</a></li>
17
14
  </ul>
18
15
  </li>
19
- <li>
16
+ <li>
20
17
  <a href="#implementation">Implementation</a>
21
18
  </li>
22
19
  <li><a href="#license">License</a></li>
23
20
  <li><a href="#contact">Contact</a></li>
21
+
24
22
  </ol>
25
23
  </details>
26
24
 
27
- <!-- ABOUT THE PROJECT -->
28
-
29
- ## About The Project
30
-
31
- Security API SDK for React.
32
-
33
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
34
-
35
25
  <!-- GETTING STARTED -->
36
26
 
37
27
  ## Getting Started
@@ -39,9 +29,9 @@ Security API SDK for React.
39
29
  The dtect Security API helps you gather valuable insights about your visitors, enhancing the quality of your survey data.
40
30
  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.
41
31
 
42
- ### Prerequisites
32
+ _Please refer to [our official documentation](https://docs.dtect.io) to read full documentation on security api_
43
33
 
44
- Get required Public Keys at [https://dtect.security.dashboard.com](https://dtect.security.dashboard.com)
34
+ _**If you want to use our API, please [contact us](https://dtect.io/contact)**_
45
35
 
46
36
  ### Installation
47
37
 
@@ -63,10 +53,14 @@ yarn add @dtect/security-sdk-react
63
53
 
64
54
  ## Implementation
65
55
 
56
+ _Read full documentation about implementation on [our official docs](https://docs.dtect.io/frontend/introduction)_
57
+
66
58
  ### 1. Wrap your application (or component) with `<SecurityAPIProvider>`.
67
59
 
68
- - Set `clientId` from your [dtect dashboard](https://dtect.security.dashboard.com/keys)
69
- - Set `apiKey` from your [dtect dashboard](https://dtect.security.dashboard.com/keys)
60
+ - Set your public client id as `clientId`
61
+ - Set your public api key as `apiKey`
62
+
63
+ Read more about keys on our [official docs](https://docs.dtect.io/credentials)
70
64
 
71
65
  ```jsx
72
66
  // index.ts or app.tsx
@@ -143,6 +137,8 @@ export default Form;
143
137
 
144
138
  ## Errors
145
139
 
140
+ _Read full documentation about errors on [our official docs](https://docs.dtect.io/errors)_
141
+
146
142
  Access the list of error enums from `SecurityAPIError`
147
143
 
148
144
  ### SecurityAPIProvider
@@ -155,6 +151,7 @@ You will see these errors on console
155
151
  | `INVALID_CREDENTIALS` | Invalid Public Client ID or Public API Key | Ensure you are using valid Public Client ID and Public API Key. |
156
152
  | `SDK_INIT_ERROR` | Internal Server Error during SDK Initialization | An unexpected error occurred on our servers during SDK initialization. |
157
153
  | `DUPLICATE_INITIALIZATION` | Multiple SDK Initializations Detected | You should initialize our package only once. |
154
+ | `MAINTENANCE_MODE` | API Under Maintenance | The API is currently undergoing maintenance and will be available again shortly. |
158
155
 
159
156
  ### getSecurityToken()/getSecurityResult()
160
157
 
@@ -164,6 +161,7 @@ You will see these errors on console
164
161
  | `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. |
165
162
  | `FAILED_TO_GET_SECURITY_TOKEN` | Failed to Generate Security Token | An error occurred while generating the Security Token. |
166
163
  | `FAILED_TO_GET_SECURITY_RESULT` | Failed to Retrieve Security Result | An error occurred while retrieving the Security Result. |
164
+ | `MAINTENANCE_MODE` | API Under Maintenance | The API is currently undergoing maintenance and will be available again shortly. |
167
165
 
168
166
  ```jsx
169
167
  // src/form.ts
@@ -208,13 +206,11 @@ function Form() {
208
206
  export default Form;
209
207
  ```
210
208
 
211
- _To see full documentation, please refer to the [Documentation](https://dtect.apidog.com)_
212
-
213
209
  <!-- LICENSE -->
214
210
 
215
- ## License
211
+ <!-- ## License
216
212
 
217
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
213
+ <p align="right">(<a href="#readme-top">back to top</a>)</p> -->
218
214
 
219
215
  <!-- CONTACT -->
220
216
 
package/dist/index.d.mts CHANGED
@@ -18,6 +18,9 @@ interface ISecurityResultResponse {
18
18
  isDuplicateId: boolean;
19
19
  isLocationBlocked: boolean;
20
20
  isLocationInvalid: boolean;
21
+ isAutomationDetected: boolean;
22
+ isUntrustedBrowserOrOS: boolean;
23
+ isBlockedIP: boolean;
21
24
  };
22
25
  }
23
26
  interface ISecurityTokenResponse {
@@ -45,6 +48,7 @@ declare const SecurityAPIError: {
45
48
  NOT_INITIALIZED: string;
46
49
  INTERNAL_SERVER_ERROR: "Internal Server Error during API Request";
47
50
  MISSING_CREDENTIALS: "Missing Public Client ID or Public API Key";
51
+ MAINTENANCE_MODE: "API Under Maintenance";
48
52
  };
49
53
 
50
54
  export { SecurityAPIError, SecurityAPIProvider, useSecurityApi };
package/dist/index.d.ts CHANGED
@@ -18,6 +18,9 @@ interface ISecurityResultResponse {
18
18
  isDuplicateId: boolean;
19
19
  isLocationBlocked: boolean;
20
20
  isLocationInvalid: boolean;
21
+ isAutomationDetected: boolean;
22
+ isUntrustedBrowserOrOS: boolean;
23
+ isBlockedIP: boolean;
21
24
  };
22
25
  }
23
26
  interface ISecurityTokenResponse {
@@ -45,6 +48,7 @@ declare const SecurityAPIError: {
45
48
  NOT_INITIALIZED: string;
46
49
  INTERNAL_SERVER_ERROR: "Internal Server Error during API Request";
47
50
  MISSING_CREDENTIALS: "Missing Public Client ID or Public API Key";
51
+ MAINTENANCE_MODE: "API Under Maintenance";
48
52
  };
49
53
 
50
54
  export { SecurityAPIError, SecurityAPIProvider, useSecurityApi };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";var k=Object.create;var u=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var L=(r,e)=>{for(var t in e)u(r,t,{get:e[t],enumerable:!0})},y=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of N(e))!v.call(r,o)&&o!==t&&u(r,o,{get:()=>e[o],enumerable:!(n=D(e,o))||n.enumerable});return r};var a=(r,e,t)=>(t=r!=null?k(O(r)):{},y(e||!r||!r.__esModule?u(t,"default",{value:r,enumerable:!0}):t,r)),w=r=>y(u({},"__esModule",{value:!0}),r);var F={};L(F,{SecurityAPIError:()=>M,SecurityAPIProvider:()=>x,useSecurityApi:()=>U});module.exports=w(F);var I=require("react");var G={UNAUTHORIZED:"Unauthorized"},p={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key"},C={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},R={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},T={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},l={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},c={...G,...p,...C,...R,...T,...l},m={...p,...C,...R,...T,...l};var S=a(require("@dtect/security-sdk-js")),A=require("react/jsx-runtime"),f=(0,I.createContext)({}),P=({children:r})=>{let e=async({projectId:n,visitorId:o,securitySettings:s,metaData:E})=>{try{return await S.default.getSecurityResult({projectId:n,visitorId:o,securitySettings:s,metaData:E})}catch(i){throw i instanceof Error?new Error(i.message):new Error(c.FAILED_TO_GET_SECURITY_RESULT)}},t=async({projectId:n,visitorId:o,securitySettings:s,metaData:E})=>{try{return await S.default.getSecurityToken({projectId:n,visitorId:o,securitySettings:s,metaData:E})}catch(i){throw i instanceof Error?new Error(i.message):new Error(c.FAILED_TO_GET_SECURITY_TOKEN)}};return(0,A.jsx)(f.Provider,{value:{getSecurityResult:e,getSecurityToken:t},children:r})},h=()=>(0,I.useContext)(f);var _=require("react"),d=a(require("@dtect/security-sdk-js"));var g=require("react/jsx-runtime"),K=({clientId:r,apiKey:e,children:t,endpoint:n})=>{let o=async()=>{try{await d.default.init({apiKey:e,clientId:r,endpoint:n})}catch(s){if(s instanceof Error){console.error(s.message);return}console.error(c.SDK_INIT_ERROR)}};if((0,_.useEffect)(()=>{r&&e&&o()},[]),!r||!e)throw new Error(c.MISSING_CREDENTIALS);return(0,g.jsx)(P,{children:t})},x=K;var U=()=>{let{getSecurityResult:r,getSecurityToken:e}=h();return{getSecurityResult:r,getSecurityToken:e}},M=m;
2
+ "use strict";var k=Object.create;var u=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var L=(r,e)=>{for(var t in e)u(r,t,{get:e[t],enumerable:!0})},a=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of D(e))!v.call(r,o)&&o!==t&&u(r,o,{get:()=>e[o],enumerable:!(n=N(e,o))||n.enumerable});return r};var y=(r,e,t)=>(t=r!=null?k(O(r)):{},a(e||!r||!r.__esModule?u(t,"default",{value:r,enumerable:!0}):t,r)),w=r=>a(u({},"__esModule",{value:!0}),r);var F={};L(F,{SecurityAPIError:()=>K,SecurityAPIProvider:()=>x,useSecurityApi:()=>U});module.exports=w(F);var E=require("react");var M={UNAUTHORIZED:"Unauthorized"},p={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key",MAINTENANCE_MODE:"API Under Maintenance"},C={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},T={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},R={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},l={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},c={...M,...p,...C,...T,...R,...l},m={...p,...C,...T,...R,...l};var S=y(require("@dtect/security-sdk-js")),h=require("react/jsx-runtime"),f=(0,E.createContext)({}),P=({children:r})=>{let e=async({projectId:n,visitorId:o,securitySettings:s,metaData:I})=>{try{return await S.default.getSecurityResult({projectId:n,visitorId:o,securitySettings:s,metaData:I})}catch(i){throw i instanceof Error?new Error(i.message):new Error(c.FAILED_TO_GET_SECURITY_RESULT)}},t=async({projectId:n,visitorId:o,securitySettings:s,metaData:I})=>{try{return await S.default.getSecurityToken({projectId:n,visitorId:o,securitySettings:s,metaData:I})}catch(i){throw i instanceof Error?new Error(i.message):new Error(c.FAILED_TO_GET_SECURITY_TOKEN)}};return(0,h.jsx)(f.Provider,{value:{getSecurityResult:e,getSecurityToken:t},children:r})},A=()=>(0,E.useContext)(f);var _=require("react"),d=y(require("@dtect/security-sdk-js"));var g=require("react/jsx-runtime"),G=({clientId:r,apiKey:e,children:t,endpoint:n})=>{let o=async()=>{try{await d.default.init({apiKey:e,clientId:r,endpoint:n})}catch(s){if(s instanceof Error){console.error(s.message);return}console.error(c.SDK_INIT_ERROR)}};if((0,_.useEffect)(()=>{r&&e&&o()},[]),!r||!e)throw new Error(c.MISSING_CREDENTIALS);return(0,g.jsx)(P,{children:t})},x=G;var U=()=>{let{getSecurityResult:r,getSecurityToken:e}=A();return{getSecurityResult:r,getSecurityToken:e}},K=m;0&&(module.exports={SecurityAPIError,SecurityAPIProvider,useSecurityApi});
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{createContext as f,useContext as P}from"react";var m={UNAUTHORIZED:"Unauthorized"},I={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"},S={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},y={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},a={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},n={...m,...I,...E,...S,...y,...a},p={...I,...E,...S,...y,...a};import C from"@dtect/security-sdk-js";import{jsx as h}from"react/jsx-runtime";var R=f({}),T=({children:r})=>{let e=async({projectId:i,visitorId:s,securitySettings:o,metaData:u})=>{try{return await C.getSecurityResult({projectId:i,visitorId:s,securitySettings:o,metaData:u})}catch(t){throw t instanceof Error?new Error(t.message):new Error(n.FAILED_TO_GET_SECURITY_RESULT)}},c=async({projectId:i,visitorId:s,securitySettings:o,metaData:u})=>{try{return await C.getSecurityToken({projectId:i,visitorId:s,securitySettings:o,metaData:u})}catch(t){throw t instanceof Error?new Error(t.message):new Error(n.FAILED_TO_GET_SECURITY_TOKEN)}};return h(R.Provider,{value:{getSecurityResult:e,getSecurityToken:c},children:r})},l=()=>P(R);import{useEffect as A}from"react";import _ from"@dtect/security-sdk-js";import{jsx as g}from"react/jsx-runtime";var d=({clientId:r,apiKey:e,children:c,endpoint:i})=>{let s=async()=>{try{await _.init({apiKey:e,clientId:r,endpoint:i})}catch(o){if(o instanceof Error){console.error(o.message);return}console.error(n.SDK_INIT_ERROR)}};if(A(()=>{r&&e&&s()},[]),!r||!e)throw new Error(n.MISSING_CREDENTIALS);return g(T,{children:c})},x=d;var er=()=>{let{getSecurityResult:r,getSecurityToken:e}=l();return{getSecurityResult:r,getSecurityToken:e}},tr=p;export{tr as SecurityAPIError,x as SecurityAPIProvider,er as useSecurityApi};
2
+ import{createContext as f,useContext as P}from"react";var m={UNAUTHORIZED:"Unauthorized"},E={INTERNAL_SERVER_ERROR:"Internal Server Error during API Request",MISSING_CREDENTIALS:"Missing Public Client ID or Public API Key",MAINTENANCE_MODE:"API Under Maintenance"},I={SDK_INIT_ERROR:"Internal Server Error during SDK Initialization",DUPLICATE_INITIALIZATION:"Multiple SDK Initializations Detected",NOT_INITIALIZED:"SDK Not Initialized"},S={INVALID_CREDENTIALS:"Invalid Public Client ID or Public API Key"},a={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},y={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},n={...m,...E,...I,...S,...a,...y},p={...E,...I,...S,...a,...y};import C from"@dtect/security-sdk-js";import{jsx as A}from"react/jsx-runtime";var T=f({}),R=({children:r})=>{let e=async({projectId:i,visitorId:s,securitySettings:o,metaData:u})=>{try{return await C.getSecurityResult({projectId:i,visitorId:s,securitySettings:o,metaData:u})}catch(t){throw t instanceof Error?new Error(t.message):new Error(n.FAILED_TO_GET_SECURITY_RESULT)}},c=async({projectId:i,visitorId:s,securitySettings:o,metaData:u})=>{try{return await C.getSecurityToken({projectId:i,visitorId:s,securitySettings:o,metaData:u})}catch(t){throw t instanceof Error?new Error(t.message):new Error(n.FAILED_TO_GET_SECURITY_TOKEN)}};return A(T.Provider,{value:{getSecurityResult:e,getSecurityToken:c},children:r})},l=()=>P(T);import{useEffect as h}from"react";import _ from"@dtect/security-sdk-js";import{jsx as g}from"react/jsx-runtime";var d=({clientId:r,apiKey:e,children:c,endpoint:i})=>{let s=async()=>{try{await _.init({apiKey:e,clientId:r,endpoint:i})}catch(o){if(o instanceof Error){console.error(o.message);return}console.error(n.SDK_INIT_ERROR)}};if(h(()=>{r&&e&&s()},[]),!r||!e)throw new Error(n.MISSING_CREDENTIALS);return g(R,{children:c})},x=d;var er=()=>{let{getSecurityResult:r,getSecurityToken:e}=l();return{getSecurityResult:r,getSecurityToken:e}},tr=p;export{tr as SecurityAPIError,x as SecurityAPIProvider,er as useSecurityApi};
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@dtect/security-sdk-react",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
8
9
  "build": "tsup src/index.ts --dts",
9
10
  "ts:check": "tsc --noEmit"
10
11
  },
11
12
  "dependencies": {
12
- "@dtect/security-sdk-js": "^0.0.6",
13
+ "@dtect/security-sdk-js": "^0.0.7",
13
14
  "@tanstack/react-query": "^5.64.1",
14
15
  "react": "^19.0.0",
15
16
  "react-dom": "^19.0.0"
@@ -6,6 +6,7 @@ const InternalError = {
6
6
  const GeneralError = {
7
7
  INTERNAL_SERVER_ERROR: "Internal Server Error during API Request",
8
8
  MISSING_CREDENTIALS: "Missing Public Client ID or Public API Key",
9
+ MAINTENANCE_MODE: "API Under Maintenance",
9
10
  } as const;
10
11
 
11
12
  const InitError = {
@@ -6,6 +6,9 @@ export interface ISecurityResultResponse {
6
6
  isDuplicateId: boolean;
7
7
  isLocationBlocked: boolean;
8
8
  isLocationInvalid: boolean;
9
+ isAutomationDetected: boolean;
10
+ isUntrustedBrowserOrOS: boolean;
11
+ isBlockedIP: boolean;
9
12
  }
10
13
  }
11
14
 
package/tsup.config.ts CHANGED
@@ -14,6 +14,5 @@ export default defineConfig({
14
14
  },
15
15
  outDir: "dist",
16
16
  format: ["cjs", "esm"],
17
- minifyIdentifiers: true,
18
- platform: "browser"
17
+ minifyIdentifiers: true
19
18
  })
@@ -1,20 +0,0 @@
1
-
2
- yarn run v1.22.22
3
- $ tsup src/index.ts --dts
4
- CLI Building entry: src/index.ts
5
- CLI Using tsconfig: tsconfig.json
6
- CLI tsup v8.3.5
7
- CLI Using tsup config: /Users/dajungha/Projects/security-sdk-react/packages/sdk-react/tsup.config.ts
8
- CLI Target: es2022
9
- CLI Cleaning output folder
10
- CJS Build start
11
- ESM Build start
12
- ESM dist/index.mjs 1.98 KB
13
- ESM ⚡️ Build success in 10ms
14
- CJS dist/index.js 2.59 KB
15
- CJS ⚡️ Build success in 11ms
16
- DTS Build start
17
- DTS ⚡️ Build success in 650ms
18
- DTS dist/index.d.ts 1.55 KB
19
- DTS dist/index.d.mts 1.55 KB
20
- ✨ Done in 1.15s.