@cuemath/leap 4.0.5-as3 → 4.0.5-as4

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.
@@ -1,8 +1,8 @@
1
1
  import { jsxs as g, jsx as e } from "react/jsx-runtime";
2
2
  import { memo as b, useCallback as I, useEffect as L } from "react";
3
- import { useLocalPeer as y, useRemotePeers as C, useCaptureMediaStreamImage as F } from "@cuemath/av";
4
- import { ILLUSTRATIONS as R } from "../../../assets/illustrations/illustrations.js";
5
- import X from "../../ui/modals/use-modal-actions.js";
3
+ import { useLocalPeer as y, useRemotePeers as C, useCaptureMediaStreamImage as R } from "@cuemath/av";
4
+ import { ILLUSTRATIONS as X } from "../../../assets/illustrations/illustrations.js";
5
+ import F from "../../ui/modals/use-modal-actions.js";
6
6
  import o from "../../ui/text/text.js";
7
7
  import _ from "../../ui/image/image.js";
8
8
  import d from "../../ui/layout/flex-view.js";
@@ -12,9 +12,9 @@ import E from "../../ui/modals/use-modal-params.js";
12
12
  import M from "../../worksheet/worksheet/hooks/use-s3-helper.js";
13
13
  import { base64ToFile as f } from "./fraud-alert-modal-helpers.js";
14
14
  const B = { type: "fraud-login" }, D = b(function() {
15
- const { closeModal: u } = X(), { teacherId: $, studentId: i, handleLogout: c } = E(), p = I(() => {
15
+ const { closeModal: u } = F(), { teacherId: $, studentId: i, handleLogout: c } = E(), p = I(() => {
16
16
  u(), c();
17
- }, [u, c]), t = y(), r = C().find((a) => a.userId === $), n = F(), l = M({
17
+ }, [u, c]), t = y(), r = C().find((a) => a.userId === $), n = R(), l = M({
18
18
  studentId: i,
19
19
  query: B
20
20
  });
@@ -22,11 +22,7 @@ const B = { type: "fraud-login" }, D = b(function() {
22
22
  if (!(r != null && r.id) || !(t != null && t.id))
23
23
  return;
24
24
  const { image: a } = n(r == null ? void 0 : r.id, "camera"), { image: A } = n(t == null ? void 0 : t.id, "camera"), m = f(a, `teacher-${Date.now()}.png`), h = f(A, `student-${Date.now()}.png`);
25
- if (!m || !h) {
26
- console.error("Failed to convert images to files");
27
- return;
28
- }
29
- l({
25
+ !m || !h || l({
30
26
  fileKey: `media/fraud-login/${i}/`,
31
27
  images: [
32
28
  { file: m, url: "teacher" },
@@ -52,7 +48,7 @@ const B = { type: "fraud-login" }, D = b(function() {
52
48
  $heightX: 3.5,
53
49
  $widthX: 3.5,
54
50
  $background: "RED_4",
55
- children: /* @__PURE__ */ e(_, { src: R.ALERT_BULB, alt: "Fraud Alert", height: 40, width: 40 })
51
+ children: /* @__PURE__ */ e(_, { src: X.ALERT_BULB, alt: "Fraud Alert", height: 40, width: 40 })
56
52
  }
57
53
  )
58
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fraud-alert-modal.js","sources":["../../../../src/features/fraud-detection/fraud-alert-modal/fraud-alert-modal.tsx"],"sourcesContent":["/**\n * Fraud Alert Modal Component\n * Displays fraud detection details and auto-logout countdown\n */\n\nimport { memo, useCallback, useEffect, useState, type FC } from 'react';\n\nimport { useCaptureMediaStreamImage, useLocalPeer, useRemotePeers } from '@cuemath/av';\n\nimport { ILLUSTRATIONS } from '../../../assets/illustrations/illustrations';\nimport useModalActions from '../../ui/modals/use-modal-actions';\nimport Text from '../../ui/text/text';\nimport Image from '../../ui/image/image';\nimport FlexView from '../../ui/layout/flex-view';\nimport Button from '../../ui/buttons/button/button';\nimport Separator from '../../ui/separator/separator';\nimport useModalParams from '../../ui/modals/use-modal-params';\nimport useS3ImageUploadHelper from '../../worksheet/worksheet/hooks/use-s3-helper';\nimport { base64ToFile } from './fraud-alert-modal-helpers';\n\nconst QUERY = { type: 'fraud-login' };\n\nconst FraudAlertModal: FC = memo(function FraudAlertModal() {\n const { closeModal } = useModalActions();\n const { teacherId, studentId, handleLogout } = useModalParams<{\n teacherId: string;\n studentId: string;\n handleLogout: () => void;\n }>();\n const onLogout = useCallback(() => {\n closeModal();\n handleLogout();\n }, [closeModal, handleLogout]);\n\n const localpeer = useLocalPeer();\n const remotePeer = useRemotePeers().find(peer => peer.userId === teacherId);\n const captureMediaStreamImage = useCaptureMediaStreamImage();\n const uploadImages = useS3ImageUploadHelper({\n studentId,\n query: QUERY,\n });\n\n useEffect(() => {\n if (!remotePeer?.id || !localpeer?.id) {\n return;\n }\n\n const { image: teacherImage } = captureMediaStreamImage(remotePeer?.id, 'camera');\n const { image: studentImage } = captureMediaStreamImage(localpeer?.id, 'camera');\n const teacherFile = base64ToFile(teacherImage, `teacher-${Date.now()}.png`);\n const studentFile = base64ToFile(studentImage, `student-${Date.now()}.png`);\n\n if (!teacherFile || !studentFile) {\n console.error('Failed to convert images to files');\n\n return;\n }\n\n uploadImages({\n fileKey: `media/fraud-login/${studentId}/`,\n images: [\n { file: teacherFile, url: 'teacher' },\n { file: studentFile, url: 'student' },\n ],\n });\n }, [captureMediaStreamImage, localpeer?.id, remotePeer?.id, studentId, uploadImages]);\n\n return (\n <FlexView $gapX={1.5} $gutterX={1.5} $background=\"RED_1\">\n <FlexView\n $justifyContent=\"center\"\n $alignItems=\"center\"\n $borderRadiusX={4}\n $heightX={4.5}\n $widthX={4.5}\n $background=\"RED_2\"\n >\n <FlexView\n $justifyContent=\"center\"\n $alignItems=\"center\"\n $borderRadiusX={4}\n $heightX={3.5}\n $widthX={3.5}\n $background=\"RED_4\"\n >\n <Image src={ILLUSTRATIONS.ALERT_BULB} alt=\"Fraud Alert\" height={40} width={40} />\n </FlexView>\n </FlexView>\n <Separator heightX={2} />\n <Text $renderAs=\"ah4-bold\" $color=\"RED_6\">\n Fraudulent Login Detected!\n </Text>\n <Separator height={12} />\n <Text $renderAs=\"ub2\" color=\"BLACK_1\">\n You have logged into a student's LEAP account, which is strictly prohibited. This is\n considered{' '}\n <Text as=\"span\" $renderAs=\"ub2-bold\" color=\"BLACK_1\" $inline>\n fraudulent activity\n </Text>{' '}\n and may result in strict action, including a{' '}\n <Text as=\"span\" $renderAs=\"ub2-bold\" color=\"BLACK_1\" $inline>\n heavy penalty\n </Text>{' '}\n or{' '}\n <Text as=\"span\" $renderAs=\"ub2-bold\" color=\"BLACK_1\" $inline>\n discontinuation\n </Text>{' '}\n from conducting Cuemath classes.\n </Text>\n <Separator heightX={2} />\n <Button\n renderAs=\"primary\"\n alignSelf=\"flex-end\"\n shape=\"square\"\n onClick={onLogout}\n label=\"Log out\"\n width=\"50%\"\n />\n </FlexView>\n );\n});\n\nexport default FraudAlertModal;\n"],"names":["QUERY","FraudAlertModal","memo","closeModal","useModalActions","teacherId","studentId","handleLogout","useModalParams","onLogout","useCallback","localpeer","useLocalPeer","remotePeer","useRemotePeers","peer","captureMediaStreamImage","useCaptureMediaStreamImage","uploadImages","useS3ImageUploadHelper","useEffect","teacherImage","studentImage","teacherFile","base64ToFile","studentFile","FlexView","jsx","Image","ILLUSTRATIONS","Separator","Text","jsxs","Button","FraudAlertModal$1"],"mappings":";;;;;;;;;;;;;AAoBA,MAAMA,IAAQ,EAAE,MAAM,iBAEhBC,IAAsBC,EAAK,WAA2B;AACpD,QAAA,EAAE,YAAAC,MAAeC,KACjB,EAAE,WAAAC,GAAW,WAAAC,GAAW,cAAAC,MAAiBC,EAI5C,GACGC,IAAWC,EAAY,MAAM;AACtB,IAAAP,KACEI;EAAA,GACZ,CAACJ,GAAYI,CAAY,CAAC,GAEvBI,IAAYC,KACZC,IAAaC,EAAe,EAAE,KAAK,CAAQC,MAAAA,EAAK,WAAWV,CAAS,GACpEW,IAA0BC,KAC1BC,IAAeC,EAAuB;AAAA,IAC1C,WAAAb;AAAA,IACA,OAAON;AAAA,EAAA,CACR;AAED,SAAAoB,EAAU,MAAM;AACd,QAAI,EAACP,KAAA,QAAAA,EAAY,OAAM,EAACF,KAAA,QAAAA,EAAW;AACjC;AAGF,UAAM,EAAE,OAAOU,MAAiBL,EAAwBH,KAAA,gBAAAA,EAAY,IAAI,QAAQ,GAC1E,EAAE,OAAOS,MAAiBN,EAAwBL,KAAA,gBAAAA,EAAW,IAAI,QAAQ,GACzEY,IAAcC,EAAaH,GAAc,WAAW,KAAK,I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AA;AAAA,MAAA;AAAA,MAEzB;AAAA,MACX,gBAAAJ,EAACI,GAAK,EAAA,IAAG,QAAO,WAAU,YAAW,OAAM,WAAU,SAAO,IAAC,UAE7D,sBAAA,CAAA;AAAA,MAAQ;AAAA,MAAI;AAAA,MACiC;AAAA,MAC7C,gBAAAJ,EAACI,GAAK,EAAA,IAAG,QAAO,WAAU,YAAW,OAAM,WAAU,SAAO,IAAC,UAE7D,gBAAA,CAAA;AAAA,MAAQ;AAAA,MAAI;AAAA,MACT;AAAA,MACH,gBAAAJ,EAACI,GAAK,EAAA,IAAG,QAAO,WAAU,YAAW,OAAM,WAAU,SAAO,IAAC,UAE7D,kBAAA,CAAA;AAAA,MAAQ;AAAA,MAAI;AAAA,IAAA,GAEd;AAAA,IACA,gBAAAJ,EAACG,GAAU,EAAA,SAAS,EAAG,CAAA;AAAA,IACvB,gBAAAH;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,UAAS;AAAA,QACT,WAAU;AAAA,QACV,OAAM;AAAA,QACN,SAASxB;AAAA,QACT,OAAM;AAAA,QACN,OAAM;AAAA,MAAA;AAAA,IACR;AAAA,EACF,EAAA,CAAA;AAEJ,CAAC,GAEDyB,IAAejC;"}
1
+ {"version":3,"file":"fraud-alert-modal.js","sources":["../../../../src/features/fraud-detection/fraud-alert-modal/fraud-alert-modal.tsx"],"sourcesContent":["import { memo, useCallback, useEffect, type FC } from 'react';\n\nimport { useCaptureMediaStreamImage, useLocalPeer, useRemotePeers } from '@cuemath/av';\n\nimport { ILLUSTRATIONS } from '../../../assets/illustrations/illustrations';\nimport useModalActions from '../../ui/modals/use-modal-actions';\nimport Text from '../../ui/text/text';\nimport Image from '../../ui/image/image';\nimport FlexView from '../../ui/layout/flex-view';\nimport Button from '../../ui/buttons/button/button';\nimport Separator from '../../ui/separator/separator';\nimport useModalParams from '../../ui/modals/use-modal-params';\nimport useS3ImageUploadHelper from '../../worksheet/worksheet/hooks/use-s3-helper';\nimport { base64ToFile } from './fraud-alert-modal-helpers';\n\nconst QUERY = { type: 'fraud-login' };\n\nconst FraudAlertModal: FC = memo(function FraudAlertModal() {\n const { closeModal } = useModalActions();\n const { teacherId, studentId, handleLogout } = useModalParams<{\n teacherId: string;\n studentId: string;\n handleLogout: () => void;\n }>();\n const onLogout = useCallback(() => {\n closeModal();\n handleLogout();\n }, [closeModal, handleLogout]);\n\n const localpeer = useLocalPeer();\n const remotePeer = useRemotePeers().find(peer => peer.userId === teacherId);\n const captureMediaStreamImage = useCaptureMediaStreamImage();\n const uploadImages = useS3ImageUploadHelper({\n studentId,\n query: QUERY,\n });\n\n useEffect(() => {\n if (!remotePeer?.id || !localpeer?.id) {\n return;\n }\n\n const { image: teacherImage } = captureMediaStreamImage(remotePeer?.id, 'camera');\n const { image: studentImage } = captureMediaStreamImage(localpeer?.id, 'camera');\n const teacherFile = base64ToFile(teacherImage, `teacher-${Date.now()}.png`);\n const studentFile = base64ToFile(studentImage, `student-${Date.now()}.png`);\n\n if (!teacherFile || !studentFile) {\n return;\n }\n\n uploadImages({\n fileKey: `media/fraud-login/${studentId}/`,\n images: [\n { file: teacherFile, url: 'teacher' },\n { file: studentFile, url: 'student' },\n ],\n });\n }, [captureMediaStreamImage, localpeer?.id, remotePeer?.id, studentId, uploadImages]);\n\n return (\n <FlexView $gapX={1.5} $gutterX={1.5} $background=\"RED_1\">\n <FlexView\n $justifyContent=\"center\"\n $alignItems=\"center\"\n $borderRadiusX={4}\n $heightX={4.5}\n $widthX={4.5}\n $background=\"RED_2\"\n >\n <FlexView\n $justifyContent=\"center\"\n $alignItems=\"center\"\n $borderRadiusX={4}\n $heightX={3.5}\n $widthX={3.5}\n $background=\"RED_4\"\n >\n <Image src={ILLUSTRATIONS.ALERT_BULB} alt=\"Fraud Alert\" height={40} width={40} />\n </FlexView>\n </FlexView>\n <Separator heightX={2} />\n <Text $renderAs=\"ah4-bold\" $color=\"RED_6\">\n Fraudulent Login Detected!\n </Text>\n <Separator height={12} />\n <Text $renderAs=\"ub2\" color=\"BLACK_1\">\n You have logged into a student's LEAP account, which is strictly prohibited. This is\n considered{' '}\n <Text as=\"span\" $renderAs=\"ub2-bold\" color=\"BLACK_1\" $inline>\n fraudulent activity\n </Text>{' '}\n and may result in strict action, including a{' '}\n <Text as=\"span\" $renderAs=\"ub2-bold\" color=\"BLACK_1\" $inline>\n heavy penalty\n </Text>{' '}\n or{' '}\n <Text as=\"span\" $renderAs=\"ub2-bold\" color=\"BLACK_1\" $inline>\n discontinuation\n </Text>{' '}\n from conducting Cuemath classes.\n </Text>\n <Separator heightX={2} />\n <Button\n renderAs=\"primary\"\n alignSelf=\"flex-end\"\n shape=\"square\"\n onClick={onLogout}\n label=\"Log out\"\n width=\"50%\"\n />\n </FlexView>\n );\n});\n\nexport default FraudAlertModal;\n"],"names":["QUERY","FraudAlertModal","memo","closeModal","useModalActions","teacherId","studentId","handleLogout","useModalParams","onLogout","useCallback","localpeer","useLocalPeer","remotePeer","useRemotePeers","peer","captureMediaStreamImage","useCaptureMediaStreamImage","uploadImages","useS3ImageUploadHelper","useEffect","teacherImage","studentImage","teacherFile","base64ToFile","studentFile","FlexView","jsx","Image","ILLUSTRATIONS","Separator","Text","jsxs","Button","FraudAlertModal$1"],"mappings":";;;;;;;;;;;;;AAeA,MAAMA,IAAQ,EAAE,MAAM,iBAEhBC,IAAsBC,EAAK,WAA2B;AACpD,QAAA,EAAE,YAAAC,MAAeC,KACjB,EAAE,WAAAC,GAAW,WAAAC,GAAW,cAAAC,MAAiBC,EAI5C,GACGC,IAAWC,EAAY,MAAM;AACtB,IAAAP,KACEI;EAAA,GACZ,CAACJ,GAAYI,CAAY,CAAC,GAEvBI,IAAYC,KACZC,IAAaC,EAAe,EAAE,KAAK,CAAQC,MAAAA,EAAK,WAAWV,CAAS,GACpEW,IAA0BC,KAC1BC,IAAeC,EAAuB;AAAA,IAC1C,WAAAb;AAAA,IACA,OAAON;AAAA,EAAA,CACR;AAED,SAAAoB,EAAU,MAAM;AACd,QAAI,EAACP,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A,sBACtBC,GAAK,EAAA,WAAU,YAAW,QAAO,SAAQ,UAE1C,8BAAA;AAAA,IACA,gBAAAJ,EAACG,GAAU,EAAA,QAAQ,GAAI,CAAA;AAAA,IACtB,gBAAAE,EAAAD,GAAA,EAAK,WAAU,OAAM,OAAM,WAAU,UAAA;AAAA,MAAA;AAAA,MAEzB;AAAA,MACX,gBAAAJ,EAACI,GAAK,EAAA,IAAG,QAAO,WAAU,YAAW,OAAM,WAAU,SAAO,IAAC,UAE7D,sBAAA,CAAA;AAAA,MAAQ;AAAA,MAAI;AAAA,MACiC;AAAA,MAC7C,gBAAAJ,EAACI,GAAK,EAAA,IAAG,QAAO,WAAU,YAAW,OAAM,WAAU,SAAO,IAAC,UAE7D,gBAAA,CAAA;AAAA,MAAQ;AAAA,MAAI;AAAA,MACT;AAAA,MACH,gBAAAJ,EAACI,GAAK,EAAA,IAAG,QAAO,WAAU,YAAW,OAAM,WAAU,SAAO,IAAC,UAE7D,kBAAA,CAAA;AAAA,MAAQ;AAAA,MAAI;AAAA,IAAA,GAEd;AAAA,IACA,gBAAAJ,EAACG,GAAU,EAAA,SAAS,EAAG,CAAA;AAAA,IACvB,gBAAAH;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,UAAS;AAAA,QACT,WAAU;AAAA,QACV,OAAM;AAAA,QACN,SAASxB;AAAA,QACT,OAAM;AAAA,QACN,OAAM;AAAA,MAAA;AAAA,IACR;AAAA,EACF,EAAA,CAAA;AAEJ,CAAC,GAEDyB,IAAejC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"device-fingerprint.js","sources":["../../../../src/features/fraud-detection/utils/device-fingerprint.ts"],"sourcesContent":["/**\n * Device fingerprinting utility for fraud detection and session tracking.\n * Generates a unique fingerprint based on device and browser characteristics.\n */\n\nimport type { IDeviceFingerprint } from './fraud-detection-types';\n\n/**\n * Create a hash from component values using djb2 hash algorithm.\n */\nconst hashComponents = (components: Record<string, unknown>): string => {\n const str = Object.keys(components)\n .sort()\n .map(key => `${key}:${components[key]}`)\n .join('|');\n\n let hash = 5381;\n\n for (let i = 0; i < str.length; i++) {\n hash = (hash * 33) ^ str.charCodeAt(i);\n }\n\n return Math.abs(hash).toString(36);\n};\n\n/**\n * Generate a device fingerprint based on browser and device characteristics.\n * Only collects properties used for fraud detection.\n */\nexport const generateDeviceFingerprint = (ipAddress: string): IDeviceFingerprint => {\n const components: Record<string, unknown> = {\n screen: `${window.screen.width}x${window.screen.height}`,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n platform: navigator.platform,\n userAgent: navigator.userAgent,\n };\n\n if ('deviceMemory' in navigator) {\n components.deviceMemory = (navigator as Navigator & { deviceMemory?: number }).deviceMemory;\n }\n\n if ('hardwareConcurrency' in navigator) {\n components.hardwareConcurrency = navigator.hardwareConcurrency;\n }\n\n const fingerprint = hashComponents(components);\n\n return {\n fingerprint,\n screen: components.screen as string,\n timezone: components.timezone as string,\n platform: components.platform as string,\n userAgent: components.userAgent as string,\n deviceMemory: components.deviceMemory as number | undefined,\n hardwareConcurrency: components.hardwareConcurrency as number | undefined,\n ip_address: ipAddress,\n };\n};\n"],"names":["hashComponents","components","str","key","hash","i","generateDeviceFingerprint","ipAddress"],"mappings":"AAUA,MAAMA,IAAiB,CAACC,MAAgD;AACtE,QAAMC,IAAM,OAAO,KAAKD,CAAU,EAC/B,OACA,IAAI,CAAAE,MAAO,GAAGA,CAAG,IAAIF,EAAWE,CAAG,CAAC,EAAE,EACtC,KAAK,GAAG;AAEX,MAAIC,IAAO;AAEX,WAASC,IAAI,GAAGA,IAAIH,EAAI,QAAQG;AAC9B,IAAAD,IAAQA,IAAO,KAAMF,EAAI,WAAWG,CAAC;AAGvC,SAAO,KAAK,IAAID,CAAI,EAAE,SAAS,EAAE;AACnC,GAMaE,IAA4B,CAACC,MAA0C;AAClF,QAAMN,IAAsC;AAAA,IAC1C,QAAQ,GAAG,OAAO,OAAO,KAAK,IAAI,OAAO,OAAO,MAAM;AAAA,IACtD,UAAU,KAAK,iBAAiB,gBAAkB,EAAA;AAAA,IAClD,UAAU,UAAU;AAAA,IACpB,WAAW,UAAU;AAAA,EAAA;AAGvB,SAAI,kBAAkB,cACpBA,EAAW,eAAgB,UAAoD,eAG7E,yBAAyB,cAC3BA,EAAW,sBAAsB,UAAU,sBAKtC;AAAA,IACL,aAHkBD,EAAeC,CAAU;AAAA,IAI3C,QAAQA,EAAW;AAAA,IACnB,UAAUA,EAAW;AAAA,IACrB,UAAUA,EAAW;AAAA,IACrB,WAAWA,EAAW;AAAA,IACtB,cAAcA,EAAW;AAAA,IACzB,qBAAqBA,EAAW;AAAA,IAChC,YAAYM;AAAA,EAAA;AAEhB;"}
1
+ {"version":3,"file":"device-fingerprint.js","sources":["../../../../src/features/fraud-detection/utils/device-fingerprint.ts"],"sourcesContent":["import type { IDeviceFingerprint } from './fraud-detection-types';\n\n/**\n * Create a hash from component values using djb2 hash algorithm.\n */\nconst hashComponents = (components: Record<string, unknown>): string => {\n const str = Object.keys(components)\n .sort()\n .map(key => `${key}:${components[key]}`)\n .join('|');\n\n let hash = 5381;\n\n for (let i = 0; i < str.length; i++) {\n hash = (hash * 33) ^ str.charCodeAt(i);\n }\n\n return Math.abs(hash).toString(36);\n};\n\n/**\n * Generate a device fingerprint based on browser and device characteristics.\n * Only collects properties used for fraud detection.\n */\nexport const generateDeviceFingerprint = (ipAddress: string): IDeviceFingerprint => {\n const components: Record<string, unknown> = {\n screen: `${window.screen.width}x${window.screen.height}`,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n platform: navigator.platform,\n userAgent: navigator.userAgent,\n };\n\n if ('deviceMemory' in navigator) {\n components.deviceMemory = (navigator as Navigator & { deviceMemory?: number }).deviceMemory;\n }\n\n if ('hardwareConcurrency' in navigator) {\n components.hardwareConcurrency = navigator.hardwareConcurrency;\n }\n\n const fingerprint = hashComponents(components);\n\n return {\n fingerprint,\n screen: components.screen as string,\n timezone: components.timezone as string,\n platform: components.platform as string,\n userAgent: components.userAgent as string,\n deviceMemory: components.deviceMemory as number | undefined,\n hardwareConcurrency: components.hardwareConcurrency as number | undefined,\n ip_address: ipAddress,\n };\n};\n"],"names":["hashComponents","components","str","key","hash","i","generateDeviceFingerprint","ipAddress"],"mappings":"AAKA,MAAMA,IAAiB,CAACC,MAAgD;AACtE,QAAMC,IAAM,OAAO,KAAKD,CAAU,EAC/B,OACA,IAAI,CAAAE,MAAO,GAAGA,CAAG,IAAIF,EAAWE,CAAG,CAAC,EAAE,EACtC,KAAK,GAAG;AAEX,MAAIC,IAAO;AAEX,WAASC,IAAI,GAAGA,IAAIH,EAAI,QAAQG;AAC9B,IAAAD,IAAQA,IAAO,KAAMF,EAAI,WAAWG,CAAC;AAGvC,SAAO,KAAK,IAAID,CAAI,EAAE,SAAS,EAAE;AACnC,GAMaE,IAA4B,CAACC,MAA0C;AAClF,QAAMN,IAAsC;AAAA,IAC1C,QAAQ,GAAG,OAAO,OAAO,KAAK,IAAI,OAAO,OAAO,MAAM;AAAA,IACtD,UAAU,KAAK,iBAAiB,gBAAkB,EAAA;AAAA,IAClD,UAAU,UAAU;AAAA,IACpB,WAAW,UAAU;AAAA,EAAA;AAGvB,SAAI,kBAAkB,cACpBA,EAAW,eAAgB,UAAoD,eAG7E,yBAAyB,cAC3BA,EAAW,sBAAsB,UAAU,sBAKtC;AAAA,IACL,aAHkBD,EAAeC,CAAU;AAAA,IAI3C,QAAQA,EAAW;AAAA,IACnB,UAAUA,EAAW;AAAA,IACrB,UAAUA,EAAW;AAAA,IACrB,WAAWA,EAAW;AAAA,IACtB,cAAcA,EAAW;AAAA,IACzB,qBAAqBA,EAAW;AAAA,IAChC,YAAYM;AAAA,EAAA;AAEhB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"hardware-profile-matcher.js","sources":["../../../../src/features/fraud-detection/utils/hardware-profile-matcher.ts"],"sourcesContent":["/**\n * Hardware profile matching utility for detecting same physical device\n * across different browsers, incognito modes, or user profiles.\n *\n * Focuses on hardware characteristics that remain constant on the same device:\n * - IP address\n * - Screen resolution\n * - Platform (OS)\n * - Timezone\n * - Hardware specs (memory, CPU cores)\n * - User agent base (ignore version numbers)\n */\n\nimport type { IDeviceFingerprint, IHardwareProfile } from './fraud-detection-types';\n\n/**\n * Extract hardware profile from device fingerprint\n */\nexport const extractHardwareProfile = (\n fingerprint: IDeviceFingerprint,\n ipAddress: string,\n): IHardwareProfile => {\n // Extract browser name without version\n const userAgent = fingerprint.userAgent.toLowerCase();\n let userAgentBase = 'unknown';\n\n if (userAgent.includes('chrome') && !userAgent.includes('edg')) {\n userAgentBase = 'chrome';\n } else if (userAgent.includes('safari') && !userAgent.includes('chrome')) {\n userAgentBase = 'safari';\n } else if (userAgent.includes('firefox')) {\n userAgentBase = 'firefox';\n } else if (userAgent.includes('edg')) {\n userAgentBase = 'edge';\n }\n\n return {\n ip_address: ipAddress,\n screen: fingerprint.screen,\n platform: fingerprint.platform,\n timezone: fingerprint.timezone,\n deviceMemory: fingerprint.deviceMemory,\n hardwareConcurrency: fingerprint.hardwareConcurrency,\n userAgentBase,\n };\n};\n\n/**\n * Check if profiles match on critical hardware fields\n * These fields must ALL match for same device detection\n */\nexport const matchesCriticalHardware = (\n profile1: IHardwareProfile,\n profile2: IHardwareProfile,\n): boolean => {\n // Must have same IP\n if (profile1.ip_address !== profile2.ip_address || profile1.ip_address === 'unknown') {\n return false;\n }\n\n // Must have same screen resolution\n if (profile1.screen !== profile2.screen) {\n return false;\n }\n\n // Must have same platform\n if (profile1.platform !== profile2.platform) {\n return false;\n }\n\n // Must have same timezone\n if (profile1.timezone !== profile2.timezone) {\n return false;\n }\n\n // If both have hardware specs, they must match\n if (profile1.deviceMemory && profile2.deviceMemory) {\n if (profile1.deviceMemory !== profile2.deviceMemory) {\n return false;\n }\n }\n\n if (profile1.hardwareConcurrency && profile2.hardwareConcurrency) {\n if (profile1.hardwareConcurrency !== profile2.hardwareConcurrency) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * Get detailed comparison for logging/debugging\n */\nexport const getHardwareComparison = (\n profile1: IHardwareProfile,\n profile2: IHardwareProfile,\n): number => {\n let score = 0;\n const weights = {\n ip_address: 30, // IP is strong indicator\n screen: 20, // Screen resolution is unique\n platform: 15, // Platform is important\n timezone: 10, // Timezone helps\n deviceMemory: 10, // Hardware specs\n hardwareConcurrency: 10, // CPU cores\n userAgentBase: 5, // Browser family (less important)\n };\n\n // IP address (exact match)\n if (profile1.ip_address === profile2.ip_address && profile1.ip_address !== 'unknown') {\n score += weights.ip_address;\n }\n\n // Screen resolution (exact match)\n if (profile1.screen === profile2.screen) {\n score += weights.screen;\n }\n\n // Platform (exact match)\n if (profile1.platform === profile2.platform) {\n score += weights.platform;\n }\n\n // Timezone (exact match)\n if (profile1.timezone === profile2.timezone) {\n score += weights.timezone;\n }\n\n // Device memory (exact match)\n if (\n profile1.deviceMemory &&\n profile2.deviceMemory &&\n profile1.deviceMemory === profile2.deviceMemory\n ) {\n score += weights.deviceMemory;\n }\n\n // Hardware concurrency (exact match)\n if (\n profile1.hardwareConcurrency &&\n profile2.hardwareConcurrency &&\n profile1.hardwareConcurrency === profile2.hardwareConcurrency\n ) {\n score += weights.hardwareConcurrency;\n }\n\n // User agent base (same browser family)\n if (profile1.userAgentBase === profile2.userAgentBase) {\n score += weights.userAgentBase;\n }\n\n return score;\n};\n"],"names":["extractHardwareProfile","fingerprint","ipAddress","userAgent","userAgentBase","matchesCriticalHardware","profile1","profile2","getHardwareComparison","score","weights"],"mappings":"AAkBa,MAAAA,IAAyB,CACpCC,GACAC,MACqB;AAEf,QAAAC,IAAYF,EAAY,UAAU,YAAY;AACpD,MAAIG,IAAgB;AAEhB,SAAAD,EAAU,SAAS,QAAQ,KAAK,CAACA,EAAU,SAAS,KAAK,IAC3CC,IAAA,WACPD,EAAU,SAAS,QAAQ,KAAK,CAACA,EAAU,SAAS,QAAQ,IACrDC,IAAA,WACPD,EAAU,SAAS,SAAS,IACrBC,IAAA,YACPD,EAAU,SAAS,KAAK,MACjBC,I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raud-detection/utils/hardware-profile-matcher.ts"],"sourcesContent":["import type { IDeviceFingerprint, IHardwareProfile } from './fraud-detection-types';\n\n/**\n * Extract hardware profile from device fingerprint\n */\nexport const extractHardwareProfile = (\n fingerprint: IDeviceFingerprint,\n ipAddress: string,\n): IHardwareProfile => {\n // Extract browser name without version\n const userAgent = fingerprint.userAgent.toLowerCase();\n let userAgentBase = 'unknown';\n\n if (userAgent.includes('chrome') && !userAgent.includes('edg')) {\n userAgentBase = 'chrome';\n } else if (userAgent.includes('safari') && !userAgent.includes('chrome')) {\n userAgentBase = 'safari';\n } else if (userAgent.includes('firefox')) {\n userAgentBase = 'firefox';\n } else if (userAgent.includes('edg')) {\n userAgentBase = 'edge';\n }\n\n return {\n ip_address: ipAddress,\n screen: fingerprint.screen,\n platform: fingerprint.platform,\n timezone: fingerprint.timezone,\n deviceMemory: fingerprint.deviceMemory,\n hardwareConcurrency: fingerprint.hardwareConcurrency,\n userAgentBase,\n };\n};\n\n/**\n * Check if profiles match on critical hardware fields\n * These fields must ALL match for same device detection\n */\nexport const matchesCriticalHardware = (\n profile1: IHardwareProfile,\n profile2: IHardwareProfile,\n): boolean => {\n // Must have same IP\n if (profile1.ip_address !== profile2.ip_address || profile1.ip_address === 'unknown') {\n return false;\n }\n\n // Must have same screen resolution\n if (profile1.screen !== profile2.screen) {\n return false;\n }\n\n // Must have same platform\n if (profile1.platform !== profile2.platform) {\n return false;\n }\n\n // Must have same timezone\n if (profile1.timezone !== profile2.timezone) {\n return false;\n }\n\n // If both have hardware specs, they must match\n if (profile1.deviceMemory && profile2.deviceMemory) {\n if (profile1.deviceMemory !== profile2.deviceMemory) {\n return false;\n }\n }\n\n if (profile1.hardwareConcurrency && profile2.hardwareConcurrency) {\n if (profile1.hardwareConcurrency !== profile2.hardwareConcurrency) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * Get detailed comparison for logging/debugging\n */\nexport const getHardwareComparison = (\n profile1: IHardwareProfile,\n profile2: IHardwareProfile,\n): number => {\n let score = 0;\n const weights = {\n ip_address: 30, // IP is strong indicator\n screen: 20, // Screen resolution is unique\n platform: 15, // Platform is important\n timezone: 10, // Timezone helps\n deviceMemory: 10, // Hardware specs\n hardwareConcurrency: 10, // CPU cores\n userAgentBase: 5, // Browser family (less important)\n };\n\n // IP address (exact match)\n if (profile1.ip_address === profile2.ip_address && profile1.ip_address !== 'unknown') {\n score += weights.ip_address;\n }\n\n // Screen resolution (exact match)\n if (profile1.screen === profile2.screen) {\n score += weights.screen;\n }\n\n // Platform (exact match)\n if (profile1.platform === profile2.platform) {\n score += weights.platform;\n }\n\n // Timezone (exact match)\n if (profile1.timezone === profile2.timezone) {\n score += weights.timezone;\n }\n\n // Device memory (exact match)\n if (\n profile1.deviceMemory &&\n profile2.deviceMemory &&\n profile1.deviceMemory === profile2.deviceMemory\n ) {\n score += weights.deviceMemory;\n }\n\n // Hardware concurrency (exact match)\n if (\n profile1.hardwareConcurrency &&\n profile2.hardwareConcurrency &&\n profile1.hardwareConcurrency === profile2.hardwareConcurrency\n ) {\n score += weights.hardwareConcurrency;\n }\n\n // User agent base (same browser family)\n if (profile1.userAgentBase === profile2.userAgentBase) {\n score += weights.userAgentBase;\n }\n\n return score;\n};\n"],"names":["extractHardwareProfile","fingerprint","ipAddress","userAgent","userAgentBase","matchesCriticalHardware","profile1","profile2","getHardwareComparison","score","weights"],"mappings":"AAKa,MAAAA,IAAyB,CACpCC,GACAC,MACqB;AAEf,QAAAC,IAAYF,EAAY,UAAU,YAAY;AACpD,MAAIG,IAAgB;AAEhB,SAAAD,EAAU,SAAS,QAAQ,KAAK,CAACA,EAAU,SAAS,KAAK,IAC3CC,IAAA,WACPD,EAAU,SAAS,QAAQ,KAAK,CAACA,EAAU,SAAS,QAAQ,IACrDC,IAAA,WACPD,EAAU,SAAS,SAAS,IACrBC,IAAA,YACPD,EAAU,SAAS,KAAK,MACjBC,IAAA,SAGX;AAAA,IACL,YAAYF;AAAA,IACZ,QAAQD,EAAY;AAAA,IACpB,UAAUA,EAAY;AAAA,IACtB,UAAUA,EAAY;AAAA,IACtB,cAAcA,EAAY;AAAA,IAC1B,qBAAqBA,EAAY;AAAA,IACjC,eAAAG;AAAA,EAAA;AAEJ,GAMaC,IAA0B,CACrCC,GACAC,MAGI,EAAAD,EAAS,eAAeC,EAAS,cAAcD,EAAS,eAAe,aAKvEA,EAAS,WAAWC,EAAS,UAK7BD,EAAS,aAAaC,EAAS,YAK/BD,EAAS,aAAaC,EAAS,YAK/BD,EAAS,gBAAgBC,EAAS,gBAChCD,EAAS,iBAAiBC,EAAS,gBAKrCD,EAAS,uBAAuBC,EAAS,uBACvCD,EAAS,wBAAwBC,EAAS,sBAWrCC,IAAwB,CACnCF,GACAC,MACW;AACX,MAAIE,IAAQ;AACZ,QAAMC,IAAU;AAAA,IACd,YAAY;AAAA;AAAA,IACZ,QAAQ;AAAA;AAAA,IACR,UAAU;AAAA;AAAA,IACV,UAAU;AAAA;AAAA,IACV,cAAc;AAAA;AAAA,IACd,qBAAqB;AAAA;AAAA,IACrB,eAAe;AAAA;AAAA,EAAA;AAIjB,SAAIJ,EAAS,eAAeC,EAAS,cAAcD,EAAS,eAAe,cACzEG,KAASC,EAAQ,aAIfJ,EAAS,WAAWC,EAAS,WAC/BE,KAASC,EAAQ,SAIfJ,EAAS,aAAaC,EAAS,aACjCE,KAASC,EAAQ,WAIfJ,EAAS,aAAaC,EAAS,aACjCE,KAASC,EAAQ,WAKjBJ,EAAS,gBACTC,EAAS,gBACTD,EAAS,iBAAiBC,EAAS,iBAEnCE,KAASC,EAAQ,eAKjBJ,EAAS,uBACTC,EAAS,uBACTD,EAAS,wBAAwBC,EAAS,wBAE1CE,KAASC,EAAQ,sBAIfJ,EAAS,kBAAkBC,EAAS,kBACtCE,KAASC,EAAQ,gBAGZD;AACT;"}
@@ -1,34 +1,31 @@
1
- import { useState as g, useMemo as h, useCallback as k, useEffect as D } from "react";
1
+ import { useState as g, useMemo as k, useCallback as h, useEffect as D } from "react";
2
2
  import { generateDeviceFingerprint as C } from "../../fraud-detection/utils/device-fingerprint.js";
3
- import { extractHardwareProfile as u, getHardwareComparison as P, matchesCriticalHardware as v } from "../../fraud-detection/utils/hardware-profile-matcher.js";
3
+ import { extractHardwareProfile as u, matchesCriticalHardware as P, getHardwareComparison as v } from "../../fraud-detection/utils/hardware-profile-matcher.js";
4
4
  const x = (f) => {
5
- const { enabled: s = !1, deviceFingerprint: e, ipAddress: t } = f, [d, l] = g(!1), r = h(() => C(t || "unknown"), [t]), o = k(async () => {
6
- if (r)
7
- try {
8
- let n = 0;
9
- const p = 3;
10
- for (; !e && n < p; )
11
- await new Promise((F) => setTimeout(F, 500)), n++;
12
- if (!e)
13
- return;
14
- const a = u(r, t || "unknown"), c = u(
15
- e,
16
- e.ip_address || "unknown"
17
- ), m = P(a, c), w = v(a, c);
18
- let i = !1;
19
- (w || r.fingerprint === e.fingerprint || t === e.ip_address && t !== "unknown" && m > 70) && (i = !0), i && l(!0);
20
- } catch (n) {
21
- console.error("[FraudDetection] Error during fraud check:", n);
22
- }
23
- }, [e, r, t]);
5
+ const { enabled: i = !1, deviceFingerprint: e, ipAddress: r } = f, [d, l] = g(!1), t = k(() => C(r || "unknown"), [r]), s = h(async () => {
6
+ if (!t)
7
+ return;
8
+ let a = 0;
9
+ const p = 3;
10
+ for (; !e && a < p; )
11
+ await new Promise((F) => setTimeout(F, 500)), a++;
12
+ if (!e)
13
+ return;
14
+ const o = u(t, r || "unknown"), c = u(
15
+ e,
16
+ e.ip_address || "unknown"
17
+ ), m = v(o, c), w = P(o, c);
18
+ let n = !1;
19
+ (w || t.fingerprint === e.fingerprint || r === e.ip_address && r !== "unknown" && m > 70) && (n = !0), n && l(!0);
20
+ }, [e, t, r]);
24
21
  return D(() => {
25
- r && e && s && o();
26
- }, [r, e, o, s]), {
22
+ t && e && i && s();
23
+ }, [t, e, s, i]), {
27
24
  isFraud: d,
28
- deviceFingerprint: r
25
+ deviceFingerprint: t
29
26
  };
30
- }, A = x;
27
+ }, M = x;
31
28
  export {
32
- A as default
29
+ M as default
33
30
  };
34
31
  //# sourceMappingURL=use-fraud-detection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-fraud-detection.js","sources":["../../../../src/features/hooks/use-fraud-detection/use-fraud-detection.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport type { IUseFraudDetection } from './use-fraud-detection-types';\nimport { generateDeviceFingerprint } from '../../fraud-detection/utils/device-fingerprint';\nimport {\n extractHardwareProfile,\n getHardwareComparison,\n matchesCriticalHardware,\n} from '../../fraud-detection/utils/hardware-profile-matcher';\n\nconst useFraudDetection: IUseFraudDetection = props => {\n const { enabled = false, deviceFingerprint, ipAddress } = props;\n const [isFraud, setIsFraud] = useState(false);\n const fp = useMemo(() => generateDeviceFingerprint(ipAddress || 'unknown'), [ipAddress]);\n\n const checkFraudDetection = useCallback(async () => {\n if (!fp) {\n return;\n }\n\n try {\n let attempts = 0;\n const maxAttempts = 3;\n\n while (!deviceFingerprint && attempts < maxAttempts) {\n await new Promise(resolve => setTimeout(resolve, 500));\n attempts++;\n }\n\n if (!deviceFingerprint) {\n return;\n }\n\n const studentProfile = extractHardwareProfile(fp, ipAddress || 'unknown');\n const teacherProfile = extractHardwareProfile(\n deviceFingerprint,\n deviceFingerprint.ip_address || 'unknown',\n );\n\n const comparison = getHardwareComparison(studentProfile, teacherProfile);\n const isCriticalMatch = matchesCriticalHardware(studentProfile, teacherProfile);\n\n let fraudDetected = false;\n\n if (isCriticalMatch) {\n fraudDetected = true;\n } else if (fp.fingerprint === deviceFingerprint.fingerprint) {\n fraudDetected = true;\n } else if (ipAddress === deviceFingerprint.ip_address && ipAddress !== 'unknown') {\n if (comparison > 70) {\n fraudDetected = true;\n }\n }\n\n if (fraudDetected) {\n setIsFraud(true);\n }\n } catch (error) {\n console.error('[FraudDetection] Error during fraud check:', error);\n }\n }, [deviceFingerprint, fp, ipAddress]);\n\n // Automatically run fraud detection when fingerprint and teacher fingerprint are both available\n useEffect(() => {\n if (fp && deviceFingerprint && enabled) {\n checkFraudDetection();\n }\n }, [fp, deviceFingerprint, checkFraudDetection, enabled]);\n\n return {\n isFraud,\n deviceFingerprint: fp,\n };\n};\n\nexport default useFraudDetection;\n"],"names":["useFraudDetection","props","enabled","deviceFingerprint","ipAddress","isFraud","setIsFraud","useState","fp","useMemo","generateDeviceFingerprint","checkFraudDetection","useCallback","attempts","maxAttempts","resolve","studentProfile","extractHardwareProfile","teacherProfile","comparison","getHardwareComparison","isCriticalMatch","matchesCriticalHardware","fraudDetected","error","useEffect","useFraudDetection$1"],"mappings":";;;AAUA,MAAMA,IAAwC,CAASC,MAAA;AACrD,QAAM,EAAE,SAAAC,IAAU,IAAO,mBAAAC,GAAmB,WAAAC,MAAcH,GACpD,CAACI,GAASC,CAAU,IAAIC,EAAS,EAAK,GACtCC,IAAKC,EAAQ,MAAMC,EAA0BN,KAAa,SAAS,GAAG,CAACA,CAAS,CAAC,GAEjFO,IAAsBC,EAAY,YAAY;AAClD,QAAKJ;AAID,UAAA;AACF,YAAIK,IAAW;AACf,cAAMC,IAAc;AAEb,eAAA,CAACX,KAAqBU,IAAWC;AACtC,gBAAM,IAAI,QAAQ,CAAAC,MAAW,WAAWA,GAAS,GAAG,CAAC,GACrDF;AAGF,YAAI,CAACV;AACH;AAGF,cAAMa,IAAiBC,EAAuBT,GAAIJ,KAAa,SAAS,GAClEc,IAAiBD;AAAA,UACrBd;AAAA,UACAA,EAAkB,cAAc;AAAA,QAAA,GAG5BgB,IAAaC,EAAsBJ,GAAgBE,CAAc,GACjEG,IAAkBC,EAAwBN,GAAgBE,CAAc;AAE9E,YAAIK,IAAgB;AAEpB,SAAIF,KAEOb,EAAG,gBAAgBL,EAAkB,eAErCC,MAAcD,EAAkB,cAAcC,MAAc,aACjEe,IAAa,QACCI,IAAA,KAIhBA,KACFjB,EAAW,EAAI;AAAA,eAEVkB,GAAO;AACN,gBAAA,MAAM,8CAA8CA,CAAK;AAAA,MACnE;AAAA,EACC,GAAA,CAACrB,GAAmBK,GAAIJ,CAAS,CAAC;AAGrC,SAAAqB,EAAU,MAAM;AACV,IAAAjB,KAAML,KAAqBD,KACTS;KAErB,CAACH,GAAIL,GAAmBQ,GAAqBT,CAAO,CAAC,GAEjD;AAAA,IACL,SAAAG;AAAA,IACA,mBAAmBG;AAAA,EAAA;AAEvB,GAEAkB,IAAe1B;"}
1
+ {"version":3,"file":"use-fraud-detection.js","sources":["../../../../src/features/hooks/use-fraud-detection/use-fraud-detection.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport type { IUseFraudDetection } from './use-fraud-detection-types';\nimport { generateDeviceFingerprint } from '../../fraud-detection/utils/device-fingerprint';\nimport {\n extractHardwareProfile,\n getHardwareComparison,\n matchesCriticalHardware,\n} from '../../fraud-detection/utils/hardware-profile-matcher';\n\nconst useFraudDetection: IUseFraudDetection = props => {\n const { enabled = false, deviceFingerprint, ipAddress } = props;\n const [isFraud, setIsFraud] = useState(false);\n const fp = useMemo(() => generateDeviceFingerprint(ipAddress || 'unknown'), [ipAddress]);\n\n const checkFraudDetection = useCallback(async () => {\n if (!fp) {\n return;\n }\n\n let attempts = 0;\n const maxAttempts = 3;\n\n while (!deviceFingerprint && attempts < maxAttempts) {\n await new Promise(resolve => setTimeout(resolve, 500));\n attempts++;\n }\n\n if (!deviceFingerprint) {\n return;\n }\n\n const studentProfile = extractHardwareProfile(fp, ipAddress || 'unknown');\n const teacherProfile = extractHardwareProfile(\n deviceFingerprint,\n deviceFingerprint.ip_address || 'unknown',\n );\n\n const comparison = getHardwareComparison(studentProfile, teacherProfile);\n const isCriticalMatch = matchesCriticalHardware(studentProfile, teacherProfile);\n\n let fraudDetected = false;\n\n if (isCriticalMatch) {\n fraudDetected = true;\n } else if (fp.fingerprint === deviceFingerprint.fingerprint) {\n fraudDetected = true;\n } else if (ipAddress === deviceFingerprint.ip_address && ipAddress !== 'unknown') {\n if (comparison > 70) {\n fraudDetected = true;\n }\n }\n\n if (fraudDetected) {\n setIsFraud(true);\n }\n }, [deviceFingerprint, fp, ipAddress]);\n\n useEffect(() => {\n if (fp && deviceFingerprint && enabled) {\n checkFraudDetection();\n }\n }, [fp, deviceFingerprint, checkFraudDetection, enabled]);\n\n return {\n isFraud,\n deviceFingerprint: fp,\n };\n};\n\nexport default useFraudDetection;\n"],"names":["useFraudDetection","props","enabled","deviceFingerprint","ipAddress","isFraud","setIsFraud","useState","fp","useMemo","generateDeviceFingerprint","checkFraudDetection","useCallback","attempts","maxAttempts","resolve","studentProfile","extractHardwareProfile","teacherProfile","comparison","getHardwareComparison","isCriticalMatch","matchesCriticalHardware","fraudDetected","useEffect","useFraudDetection$1"],"mappings":";;;AAUA,MAAMA,IAAwC,CAASC,MAAA;AACrD,QAAM,EAAE,SAAAC,IAAU,IAAO,mBAAAC,GAAmB,WAAAC,MAAcH,GACpD,CAACI,GAASC,CAAU,IAAIC,EAAS,EAAK,GACtCC,IAAKC,EAAQ,MAAMC,EAA0BN,KAAa,SAAS,GAAG,CAACA,CAAS,CAAC,GAEjFO,IAAsBC,EAAY,YAAY;AAClD,QAAI,CAACJ;AACH;AAGF,QAAIK,IAAW;AACf,UAAMC,IAAc;AAEb,WAAA,CAACX,KAAqBU,IAAWC;AACtC,YAAM,IAAI,QAAQ,CAAAC,MAAW,WAAWA,GAAS,GAAG,CAAC,GACrDF;AAGF,QAAI,CAACV;AACH;AAGF,UAAMa,IAAiBC,EAAuBT,GAAIJ,KAAa,SAAS,GAClEc,IAAiBD;AAAA,MACrBd;AAAA,MACAA,EAAkB,cAAc;AAAA,IAAA,GAG5BgB,IAAaC,EAAsBJ,GAAgBE,CAAc,GACjEG,IAAkBC,EAAwBN,GAAgBE,CAAc;AAE9E,QAAIK,IAAgB;AAEpB,KAAIF,KAEOb,EAAG,gBAAgBL,EAAkB,eAErCC,MAAcD,EAAkB,cAAcC,MAAc,aACjEe,IAAa,QACCI,IAAA,KAIhBA,KACFjB,EAAW,EAAI;AAAA,EAEhB,GAAA,CAACH,GAAmBK,GAAIJ,CAAS,CAAC;AAErC,SAAAoB,EAAU,MAAM;AACV,IAAAhB,KAAML,KAAqBD,KACTS;KAErB,CAACH,GAAIL,GAAmBQ,GAAqBT,CAAO,CAAC,GAEjD;AAAA,IACL,SAAAG;AAAA,IACA,mBAAmBG;AAAA,EAAA;AAEvB,GAEAiB,IAAezB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuemath/leap",
3
- "version": "4.0.5-as3",
3
+ "version": "4.0.5-as4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"