@alfabit/keycloak 0.0.47 → 0.0.48

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alfabit/keycloak",
3
3
  "private": false,
4
- "version": "0.0.47",
4
+ "version": "0.0.48",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
7
7
  "main": "src/index.ts",
@@ -3,8 +3,11 @@ import { getToken } from '../../../composables';
3
3
  import { useAnalytics } from '@alfabit/analitics';
4
4
 
5
5
  export const postWebLogin = async () => {
6
+ console.log('postWebLogin 1');
6
7
  if (typeof window === 'undefined') return;
7
8
 
9
+ console.log('postWebLogin 2');
10
+
8
11
  const referral_token = localStorage.getItem(REF_KEY) ?? null;
9
12
  const headers: Record<string, string> = {
10
13
  "Content-Type": "application/json",
@@ -15,32 +18,60 @@ export const postWebLogin = async () => {
15
18
  let url = `${WALLET_API_HOST}/public/web/login/`;
16
19
 
17
20
  try {
21
+
22
+ console.log('postWebLogin 3');
23
+
18
24
  const analytics = useAnalytics();
25
+
26
+ console.log('postWebLogin 4');
27
+
19
28
  const clientID = await analytics.getClientID();
29
+
30
+ console.log('postWebLogin 5', { clientID });
31
+
32
+
20
33
  if (clientID) {
21
34
  const urlObj = new URL(url);
22
35
  urlObj.searchParams.set('ym_client_id', clientID);
23
36
  url = urlObj.toString();
24
37
  }
25
38
  else throw new Error();
39
+
40
+ console.log('postWebLogin 6', { url });
41
+
26
42
  } catch (error) {
43
+ console.log('postWebLogin 7', { error });
27
44
  console.warn('Failed to get analytics clientID:', error);
28
45
  }
29
46
 
47
+ console.log('postWebLogin 8', { url });
48
+
30
49
  const params: RequestInit = {
31
50
  method: "POST",
32
51
  headers,
33
52
  body: JSON.stringify({ referral_token })
34
53
  }
35
54
 
55
+ console.log('postWebLogin 9', { params });
56
+
36
57
  const res = await fetch(url, params);
37
58
 
59
+ console.log('postWebLogin 10', { res });
60
+
38
61
  if (!res.ok) {
39
62
  throw new Error(`postWebLogin /public/web/login/: HTTP error: ${res.status}`);
40
63
  }
41
64
 
65
+ console.log('postWebLogin 11', { res });
66
+
42
67
  const data = await res.json();
68
+
69
+ console.log('postWebLogin 12', { data });
70
+
43
71
  if (referral_token) localStorage.removeItem(REF_KEY);
72
+
73
+ console.log('postWebLogin 13', { data });
74
+
44
75
  return data;
45
76
  };
46
77
 
@@ -69,4 +100,4 @@ export const getPublicProfile = async () => {
69
100
 
70
101
  const data = await res.json();
71
102
  return data;
72
- };
103
+ };
@@ -455,11 +455,14 @@ export async function initKeycloak() {
455
455
  });
456
456
 
457
457
  const res = await keycloak.value.init(initOptions);
458
+ isAuth.value = keycloak.value?.authenticated || false;
458
459
 
459
460
  checkAuth.value = true;
460
461
 
461
462
  console.log('initKeycloak', {
462
463
  res,
464
+ keycloak: keycloak.value,
465
+ isAuth: isAuth.value,
463
466
  });
464
467
 
465
468
  setTokens();