@dtect/security-sdk-react 0.0.7 → 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
@@ -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,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,10 +1,11 @@
1
1
  {
2
2
  "name": "@dtect/security-sdk-react",
3
- "version": "0.0.7",
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
  },
@@ -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
 
@@ -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.