@opexa/portal-components 0.0.1127 → 0.0.1129

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.
@@ -4,6 +4,5 @@ import type { Authenticator, MutationConfig } from '../../types';
4
4
  import { type SignInInput } from '../services/signIn';
5
5
  export interface UseSignInMutationOptions extends MutationConfig<Authenticator | null, SignInInput> {
6
6
  versionSession?: VersionSession;
7
- fingerprint?: () => Promise<string | null> | string | null;
8
7
  }
9
8
  export declare const useSignInMutation: (options?: UseSignInMutationOptions) => UseMutationResult<Authenticator | null, Error, SignInInput>;
@@ -1,7 +1,8 @@
1
1
  import { Capacitor } from '@capacitor/core';
2
2
  import { useMutation } from '@tanstack/react-query';
3
+ import { Thumbmark } from '@thumbmarkjs/thumbmarkjs';
3
4
  import { useReCaptcha } from 'next-recaptcha-v3';
4
- import { FINGERPRINT_HEADER_KEY, RECAPTCHA_HEADER_KEY, } from '../../constants/index.js';
5
+ import { FINGERPRINT_HEADER_KEY, RECAPTCHA_HEADER_KEY } from '../../constants/index.js';
5
6
  import { getQueryClient } from '../../utils/getQueryClient.js';
6
7
  import { getSignInMutationKey } from '../../utils/mutationKeys.js';
7
8
  import { getSessionQueryKey } from '../../utils/queryKeys.js';
@@ -10,7 +11,7 @@ import { signIn } from '../services/signIn.js';
10
11
  export const useSignInMutation = (options) => {
11
12
  const queryClient = getQueryClient();
12
13
  const recaptcha = useReCaptcha();
13
- const { fingerprint, versionSession, ...config } = options ?? {};
14
+ const { versionSession, ...config } = options ?? {};
14
15
  return useMutation({
15
16
  ...config,
16
17
  mutationKey: getSignInMutationKey(),
@@ -19,9 +20,7 @@ export const useSignInMutation = (options) => {
19
20
  const token = recaptcha.reCaptchaKey
20
21
  ? await recaptcha.executeRecaptcha('submit')
21
22
  : null;
22
- const fingerprintValue = versionSession === 'Inplay' && input.type === 'NAME_AND_PASSWORD'
23
- ? await Promise.resolve(fingerprint?.()).catch(() => null)
24
- : null;
23
+ const fingerprint = versionSession === 'Inplay' ? await getFingerprint() : null;
25
24
  const authenticator = await signIn(input, {
26
25
  headers: {
27
26
  ...(token && {
@@ -30,8 +29,8 @@ export const useSignInMutation = (options) => {
30
29
  ...(session.domain && {
31
30
  Domain: session.domain,
32
31
  }),
33
- ...(fingerprintValue && {
34
- [FINGERPRINT_HEADER_KEY]: fingerprintValue,
32
+ ...(fingerprint && {
33
+ [FINGERPRINT_HEADER_KEY]: fingerprint,
35
34
  }),
36
35
  ...(Capacitor.getPlatform() === 'android'
37
36
  ? { Channel: 'ANDROID' }
@@ -47,3 +46,26 @@ export const useSignInMutation = (options) => {
47
46
  },
48
47
  });
49
48
  };
49
+ let thumbmark_instance;
50
+ async function getFingerprint() {
51
+ if (typeof window === 'undefined')
52
+ return null;
53
+ if (!thumbmark_instance) {
54
+ thumbmark_instance = new Thumbmark({
55
+ logging: false,
56
+ timeout: 30000,
57
+ cache_lifetime_in_ms: 1 * 60 * 60 * 1000 /* 1h */,
58
+ });
59
+ }
60
+ try {
61
+ const cached = sessionStorage.getItem('fingerprint');
62
+ if (cached)
63
+ return cached;
64
+ const result = await thumbmark_instance.get();
65
+ sessionStorage.setItem('fingerprint', result.thumbmark);
66
+ return result.thumbmark;
67
+ }
68
+ catch {
69
+ return null;
70
+ }
71
+ }
@@ -45,7 +45,6 @@ export function NameAndPasswordSignIn() {
45
45
  disclaimer: ctx.disclaimer,
46
46
  })));
47
47
  const signInMutation = useSignInMutation({
48
- fingerprint: signInProps.fingerprint,
49
48
  versionSession: signInProps.versionSession,
50
49
  onSuccess: async (authenticator) => {
51
50
  if (authenticator) {
@@ -42,7 +42,6 @@ export function NameAndPasswordSignIn() {
42
42
  disclaimer: ctx.disclaimer,
43
43
  })));
44
44
  const signInMutation = useSignInMutation({
45
- fingerprint: signInProps.fingerprint,
46
45
  versionSession: signInProps.versionSession,
47
46
  onSuccess: async (authenticator) => {
48
47
  if (authenticator) {
@@ -55,7 +55,6 @@ export function NameAndPasswordSignIn() {
55
55
  })));
56
56
  const [formType, setFormType] = useState('NAME_AND_PASSWORD');
57
57
  const signInMutation = useSignInMutation({
58
- fingerprint: signInProps.fingerprint,
59
58
  versionSession: signInProps.versionSession,
60
59
  onSuccess: async (authenticator) => {
61
60
  if (authenticator) {
@@ -33,11 +33,10 @@ export function UpdateMobilePhoneNumber() {
33
33
  const account = accountQuery.data;
34
34
  const isAccountLoading = accountQuery.isLoading;
35
35
  const isMobileNumberVerified = account?.mobileNumberVerified === true;
36
- const hasNoMobileNumber = account?.mobileNumber == null;
37
36
  const hasExecuted = useRef(false);
38
37
  useEffect(() => {
39
38
  if (!isAccountLoading && !!account && !hasExecuted.current) {
40
- if (!isMobileNumberVerified && hasNoMobileNumber) {
39
+ if (!isMobileNumberVerified) {
41
40
  globalStore.updateMobilePhoneNumber.setOpen(true);
42
41
  }
43
42
  else {
@@ -49,7 +48,6 @@ export function UpdateMobilePhoneNumber() {
49
48
  isAccountLoading,
50
49
  account,
51
50
  isMobileNumberVerified,
52
- hasNoMobileNumber,
53
51
  globalStore.updateMobilePhoneNumber,
54
52
  ]);
55
53
  const [step, setStep] = useState(1);
@@ -8,7 +8,9 @@ const SESSION_ENDPOINTS = {
8
8
  export async function createSession(input, options, versionSession = 'default') {
9
9
  const headers = new Headers();
10
10
  if (input.type === 'NAME_AND_PASSWORD') {
11
- const password = await sha256(input.password);
11
+ const password = versionSession === 'Inplay'
12
+ ? input.password
13
+ : await sha256(input.password);
12
14
  headers.set('Authorization', `Basic ${Buffer.from(`${input.name}:${password}`).toString('base64')}`);
13
15
  }
14
16
  if (input.type === 'MOBILE_NUMBER') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.1127",
3
+ "version": "0.0.1129",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",
@@ -98,6 +98,7 @@
98
98
  "@sumsub/websdk": "^2.3.18",
99
99
  "@sumsub/websdk-react": "^2.3.18",
100
100
  "@tailwindcss/typography": "^0.5.16",
101
+ "@thumbmarkjs/thumbmarkjs": "^1.7.4",
101
102
  "capacitor-native-biometric": "^4.2.2",
102
103
  "capacitor-plugin-safe-area": "^4.0.0",
103
104
  "date-fns": "^4.1.0",