@dtect/security-sdk-react 0.0.12 → 0.0.14

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/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { PropsWithChildren } from 'react';
3
2
 
4
3
  interface ISecurityCheckInput {
5
4
  projectId: string;
@@ -35,10 +34,11 @@ interface ISecurityTokenResponse {
35
34
  token: string;
36
35
  }
37
36
 
38
- interface SecurityAPIProviderProps extends PropsWithChildren {
37
+ interface SecurityAPIProviderProps {
39
38
  clientId: string;
40
39
  apiKey: string;
41
40
  endpoint?: string;
41
+ children: React.ReactNode;
42
42
  }
43
43
  declare const SecurityAPIProvider: ({ clientId, apiKey, children, endpoint, }: SecurityAPIProviderProps) => react_jsx_runtime.JSX.Element;
44
44
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { PropsWithChildren } from 'react';
3
2
 
4
3
  interface ISecurityCheckInput {
5
4
  projectId: string;
@@ -35,10 +34,11 @@ interface ISecurityTokenResponse {
35
34
  token: string;
36
35
  }
37
36
 
38
- interface SecurityAPIProviderProps extends PropsWithChildren {
37
+ interface SecurityAPIProviderProps {
39
38
  clientId: string;
40
39
  apiKey: string;
41
40
  endpoint?: string;
41
+ children: React.ReactNode;
42
42
  }
43
43
  declare const SecurityAPIProvider: ({ clientId, apiKey, children, endpoint, }: SecurityAPIProviderProps) => react_jsx_runtime.JSX.Element;
44
44
 
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,L=Object.prototype.hasOwnProperty;var v=(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 N(e))!L.call(r,o)&&o!==t&&u(r,o,{get:()=>e[o],enumerable:!(n=D(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={};v(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",RATE_LIMIT_REACHED:"Too many requests. Rate limit exceeded"},T={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"},C={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},l={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},c={...M,...p,...T,...R,...C,...l},m={...p,...T,...R,...C,...l};var S=y(require("@dtect/security-sdk-js")),_=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,_.jsx)(f.Provider,{value:{getSecurityResult:e,getSecurityToken:t},children:r})},A=()=>(0,E.useContext)(f);var d=require("react"),h=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 h.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,d.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});
2
+ "use strict";var g=Object.create;var u=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var v=(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))!L.call(r,o)&&o!==t&&u(r,o,{get:()=>e[o],enumerable:!(n=k(e,o))||n.enumerable});return r};var y=(r,e,t)=>(t=r!=null?g(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={};v(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",RATE_LIMIT_REACHED:"Too many requests. Rate limit exceeded"},R={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"},C={FAILED_TO_GET_SECURITY_RESULT:"Failed to Retrieve Security Result"},l={FAILED_TO_GET_SECURITY_TOKEN:" Failed to Generate Security Token"},s={...M,...p,...R,...T,...C,...l},m={...p,...R,...T,...C,...l};var S=y(require("@dtect/security-sdk-js")),_=require("react/jsx-runtime"),f=(0,E.createContext)({}),P=({children:r})=>{let e=async({projectId:n,visitorId:o,securitySettings:c,metaData:I})=>{try{return await S.default.getSecurityResult({projectId:n,visitorId:o,securitySettings:c,metaData:I})}catch(i){throw i instanceof Error?new Error(i.message):new Error(s.FAILED_TO_GET_SECURITY_RESULT)}},t=async({projectId:n,visitorId:o,securitySettings:c,metaData:I})=>{try{return await S.default.getSecurityToken({projectId:n,visitorId:o,securitySettings:c,metaData:I})}catch(i){throw i instanceof Error?new Error(i.message):new Error(s.FAILED_TO_GET_SECURITY_TOKEN)}};return(0,_.jsx)(f.Provider,{value:{getSecurityResult:e,getSecurityToken:t},children:r})},A=()=>(0,E.useContext)(f);var d=require("react"),h=y(require("@dtect/security-sdk-js"));var N=require("react/jsx-runtime"),G=({clientId:r,apiKey:e,children:t,endpoint:n})=>{let o=async()=>{try{await h.default.init({apiKey:e,clientId:r,endpoint:n})}catch(c){if(c instanceof Error){console.error(c.message);return}console.error(s.SDK_INIT_ERROR)}};if((0,d.useEffect)(()=>{r&&e&&o()},[]),!r||!e)throw new Error(s.MISSING_CREDENTIALS);return(0,N.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"},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",RATE_LIMIT_REACHED:"Too many requests. Rate limit exceeded"},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 T from"@dtect/security-sdk-js";import{jsx as A}from"react/jsx-runtime";var R=f({}),C=({children:r})=>{let e=async({projectId:i,visitorId:s,securitySettings:o,metaData:u})=>{try{return await T.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 T.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(R.Provider,{value:{getSecurityResult:e,getSecurityToken:c},children:r})},l=()=>P(R);import{useEffect as _}from"react";import d from"@dtect/security-sdk-js";import{jsx as g}from"react/jsx-runtime";var h=({clientId:r,apiKey:e,children:c,endpoint:i})=>{let s=async()=>{try{await d.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(_(()=>{r&&e&&s()},[]),!r||!e)throw new Error(n.MISSING_CREDENTIALS);return g(C,{children:c})},x=h;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",RATE_LIMIT_REACHED:"Too many requests. Rate limit exceeded"},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 R from"@dtect/security-sdk-js";import{jsx as A}from"react/jsx-runtime";var T=f({}),C=({children:r})=>{let e=async({projectId:i,visitorId:c,securitySettings:o,metaData:u})=>{try{return await R.getSecurityResult({projectId:i,visitorId:c,securitySettings:o,metaData:u})}catch(t){throw t instanceof Error?new Error(t.message):new Error(n.FAILED_TO_GET_SECURITY_RESULT)}},s=async({projectId:i,visitorId:c,securitySettings:o,metaData:u})=>{try{return await R.getSecurityToken({projectId:i,visitorId:c,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:s},children:r})},l=()=>P(T);import{useEffect as _}from"react";import d from"@dtect/security-sdk-js";import{jsx as N}from"react/jsx-runtime";var h=({clientId:r,apiKey:e,children:s,endpoint:i})=>{let c=async()=>{try{await d.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(_(()=>{r&&e&&c()},[]),!r||!e)throw new Error(n.MISSING_CREDENTIALS);return N(C,{children:s})},x=h;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,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtect/security-sdk-react",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -10,14 +10,14 @@
10
10
  "ts:check": "tsc --noEmit"
11
11
  },
12
12
  "dependencies": {
13
- "@dtect/security-sdk-js": "^0.0.12",
13
+ "@dtect/security-sdk-js": "^0.0.14",
14
14
  "@tanstack/react-query": "^5.64.1",
15
- "react": "^19.0.0",
16
- "react-dom": "^19.0.0"
15
+ "react": "^18.3.1",
16
+ "react-dom": "^18.3.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@eslint/js": "^9.17.0",
20
- "@types/react": "^19.0.2",
20
+ "@types/react": "^18.3.1",
21
21
  "eslint": "^9.17.0",
22
22
  "eslint-plugin-react-hooks": "^5.1.0",
23
23
  "tsup": "^8.3.5",
@@ -29,5 +29,9 @@
29
29
  "description": "",
30
30
  "publishConfig": {
31
31
  "access": "public"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "^18.3.1",
35
+ "react-dom": "^18.3.1"
32
36
  }
33
37
  }
@@ -5,10 +5,11 @@ import dtect from "@dtect/security-sdk-js";
5
5
  import { SecurityCheckContextProvider } from "../context";
6
6
  import { ErrorMessageEnum } from "../types";
7
7
 
8
- interface SecurityAPIProviderProps extends PropsWithChildren {
8
+ interface SecurityAPIProviderProps {
9
9
  clientId: string;
10
10
  apiKey: string;
11
11
  endpoint?: string;
12
+ children: React.ReactNode;
12
13
  }
13
14
 
14
15
  const SecurityAPIProvider = ({