@dtect/security-sdk-react 0.0.7 → 0.0.9
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 +2 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -2
- package/src/types/error.ts +1 -0
- package/src/types/response.ts +11 -0
- package/.turbo/turbo-build.log +0 -20
package/README.md
CHANGED
|
@@ -151,6 +151,7 @@ You will see these errors on console
|
|
|
151
151
|
| `INVALID_CREDENTIALS` | Invalid Public Client ID or Public API Key | Ensure you are using valid Public Client ID and Public API Key. |
|
|
152
152
|
| `SDK_INIT_ERROR` | Internal Server Error during SDK Initialization | An unexpected error occurred on our servers during SDK initialization. |
|
|
153
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. |
|
|
154
155
|
|
|
155
156
|
### getSecurityToken()/getSecurityResult()
|
|
156
157
|
|
|
@@ -160,6 +161,7 @@ You will see these errors on console
|
|
|
160
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. |
|
|
161
162
|
| `FAILED_TO_GET_SECURITY_TOKEN` | Failed to Generate Security Token | An error occurred while generating the Security Token. |
|
|
162
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. |
|
|
163
165
|
|
|
164
166
|
```jsx
|
|
165
167
|
// src/form.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,17 @@ interface ISecurityResultResponse {
|
|
|
18
18
|
isDuplicateId: boolean;
|
|
19
19
|
isLocationBlocked: boolean;
|
|
20
20
|
isLocationInvalid: boolean;
|
|
21
|
+
isAutomationDetected: boolean;
|
|
22
|
+
isUntrustedBrowserOrOS: boolean;
|
|
23
|
+
isBlockedIP: boolean;
|
|
24
|
+
isVpnDetected: boolean;
|
|
25
|
+
isDeviceTampered: boolean;
|
|
26
|
+
isVirtualMachine: boolean;
|
|
27
|
+
isDevToolsOpened: boolean;
|
|
28
|
+
isPrivacySettingsEnabled: boolean;
|
|
29
|
+
isTorDetected: boolean;
|
|
30
|
+
isHighActivityDevice: boolean;
|
|
31
|
+
isIncognito: boolean;
|
|
21
32
|
};
|
|
22
33
|
}
|
|
23
34
|
interface ISecurityTokenResponse {
|
|
@@ -45,6 +56,7 @@ declare const SecurityAPIError: {
|
|
|
45
56
|
NOT_INITIALIZED: string;
|
|
46
57
|
INTERNAL_SERVER_ERROR: "Internal Server Error during API Request";
|
|
47
58
|
MISSING_CREDENTIALS: "Missing Public Client ID or Public API Key";
|
|
59
|
+
MAINTENANCE_MODE: "API Under Maintenance";
|
|
48
60
|
};
|
|
49
61
|
|
|
50
62
|
export { SecurityAPIError, SecurityAPIProvider, useSecurityApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,17 @@ interface ISecurityResultResponse {
|
|
|
18
18
|
isDuplicateId: boolean;
|
|
19
19
|
isLocationBlocked: boolean;
|
|
20
20
|
isLocationInvalid: boolean;
|
|
21
|
+
isAutomationDetected: boolean;
|
|
22
|
+
isUntrustedBrowserOrOS: boolean;
|
|
23
|
+
isBlockedIP: boolean;
|
|
24
|
+
isVpnDetected: boolean;
|
|
25
|
+
isDeviceTampered: boolean;
|
|
26
|
+
isVirtualMachine: boolean;
|
|
27
|
+
isDevToolsOpened: boolean;
|
|
28
|
+
isPrivacySettingsEnabled: boolean;
|
|
29
|
+
isTorDetected: boolean;
|
|
30
|
+
isHighActivityDevice: boolean;
|
|
31
|
+
isIncognito: boolean;
|
|
21
32
|
};
|
|
22
33
|
}
|
|
23
34
|
interface ISecurityTokenResponse {
|
|
@@ -45,6 +56,7 @@ declare const SecurityAPIError: {
|
|
|
45
56
|
NOT_INITIALIZED: string;
|
|
46
57
|
INTERNAL_SERVER_ERROR: "Internal Server Error during API Request";
|
|
47
58
|
MISSING_CREDENTIALS: "Missing Public Client ID or Public API Key";
|
|
59
|
+
MAINTENANCE_MODE: "API Under Maintenance";
|
|
48
60
|
};
|
|
49
61
|
|
|
50
62
|
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
|
|
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"},
|
|
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.
|
|
3
|
+
"version": "0.0.9",
|
|
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.
|
|
13
|
+
"@dtect/security-sdk-js": "^0.0.9",
|
|
13
14
|
"@tanstack/react-query": "^5.64.1",
|
|
14
15
|
"react": "^19.0.0",
|
|
15
16
|
"react-dom": "^19.0.0"
|
package/src/types/error.ts
CHANGED
|
@@ -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 = {
|
package/src/types/response.ts
CHANGED
|
@@ -6,6 +6,17 @@ export interface ISecurityResultResponse {
|
|
|
6
6
|
isDuplicateId: boolean;
|
|
7
7
|
isLocationBlocked: boolean;
|
|
8
8
|
isLocationInvalid: boolean;
|
|
9
|
+
isAutomationDetected: boolean;
|
|
10
|
+
isUntrustedBrowserOrOS: boolean;
|
|
11
|
+
isBlockedIP: boolean;
|
|
12
|
+
isVpnDetected: boolean;
|
|
13
|
+
isDeviceTampered: boolean;
|
|
14
|
+
isVirtualMachine: boolean;
|
|
15
|
+
isDevToolsOpened: boolean;
|
|
16
|
+
isPrivacySettingsEnabled: boolean;
|
|
17
|
+
isTorDetected: boolean;
|
|
18
|
+
isHighActivityDevice: boolean;
|
|
19
|
+
isIncognito: boolean;
|
|
9
20
|
}
|
|
10
21
|
}
|
|
11
22
|
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
[2K[1G[1myarn run v1.22.22[22m
|
|
3
|
-
[2K[1G[2m$ tsup src/index.ts --dts[22m
|
|
4
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
5
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
6
|
-
[34mCLI[39m tsup v8.3.5
|
|
7
|
-
[34mCLI[39m Using tsup config: /Users/dajungha/Projects/security-sdk-react/packages/sdk-react/tsup.config.ts
|
|
8
|
-
[34mCLI[39m Target: es2022
|
|
9
|
-
[34mCLI[39m Cleaning output folder
|
|
10
|
-
[34mCJS[39m Build start
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m1.98 KB[39m
|
|
13
|
-
[32mESM[39m ⚡️ Build success in 10ms
|
|
14
|
-
[32mCJS[39m [1mdist/index.js [22m[32m2.59 KB[39m
|
|
15
|
-
[32mCJS[39m ⚡️ 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
|
-
[2K[1G✨ Done in 1.15s.
|