@alfabit/keycloak 0.0.41 → 0.0.42
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.
|
|
4
|
+
"version": "0.0.42",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"main": "src/index.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"keycloak-js": "^26.2.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@alfabit/constants": "^0.0.21",
|
|
24
23
|
"@alfabit/analitics": "^0.0.18",
|
|
24
|
+
"@alfabit/constants": "^0.0.21",
|
|
25
25
|
"@intlify/unplugin-vue-i18n": "^6.0.8",
|
|
26
26
|
"@tanstack/vue-query": "^5.72.0",
|
|
27
27
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -9,11 +9,11 @@ export const postWebLogin = async () => {
|
|
|
9
9
|
const headers: Record<string, string> = {
|
|
10
10
|
"Content-Type": "application/json",
|
|
11
11
|
};
|
|
12
|
-
const token = getToken();
|
|
13
|
-
if(token) headers['Authorization'] = `Bearer ${token}`;
|
|
12
|
+
const token = getToken();
|
|
13
|
+
if (token) headers['Authorization'] = `Bearer ${token}`;
|
|
14
14
|
|
|
15
15
|
let url = `${WALLET_API_HOST}/public/web/login/`;
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
try {
|
|
18
18
|
const analytics = useAnalytics();
|
|
19
19
|
const clientID = await analytics.getClientID();
|
|
@@ -41,4 +41,31 @@ export const postWebLogin = async () => {
|
|
|
41
41
|
const data = await res.json();
|
|
42
42
|
if (referral_token) localStorage.removeItem(REF_KEY);
|
|
43
43
|
return data;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
export const getPublicProfile = async () => {
|
|
48
|
+
if (typeof window === 'undefined') return;
|
|
49
|
+
|
|
50
|
+
const headers: Record<string, string> = {
|
|
51
|
+
"Content-Type": "application/json",
|
|
52
|
+
};
|
|
53
|
+
const token = getToken();
|
|
54
|
+
if (token) headers['Authorization'] = `Bearer ${token}`;
|
|
55
|
+
|
|
56
|
+
let url = `${WALLET_API_HOST}/public/getProfile`;
|
|
57
|
+
|
|
58
|
+
const params: RequestInit = {
|
|
59
|
+
method: "GET",
|
|
60
|
+
headers,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const res = await fetch(url, params);
|
|
64
|
+
|
|
65
|
+
if (!res.ok) {
|
|
66
|
+
throw new Error(`postWebLogin /public/web/login/: HTTP error: ${res.status}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const data = await res.json();
|
|
70
|
+
return data;
|
|
44
71
|
};
|
|
@@ -1,10 +1,52 @@
|
|
|
1
1
|
import Keycloak, { type KeycloakInitOptions } from 'keycloak-js';
|
|
2
2
|
import { inject, reactive, readonly, type Ref, ref } from 'vue';
|
|
3
|
-
import { postWebLogin } from '../api/wallet/endpoints';
|
|
3
|
+
import { postWebLogin, getPublicProfile } from '../api/wallet/endpoints';
|
|
4
4
|
import { AppNameEnum, APP_NAME, IS_TELEGRAM_MINI_APP, KEYCLOAK_LOGIN_REQUIRED, OPENID_CLIENT_ID, OPENID_REALM, OPENID_URL, LocationEnum, IS_LOCALHOST } from '@alfabit/constants';
|
|
5
5
|
|
|
6
6
|
export type TIdpHint = 'email' | 'google' | 'apple';
|
|
7
7
|
|
|
8
|
+
enum TariffsGridTypeEnum {
|
|
9
|
+
Deposit = 'deposit',
|
|
10
|
+
Withdraw = 'withdraw',
|
|
11
|
+
Invoice = 'invoice',
|
|
12
|
+
Hedging = 'hedging',
|
|
13
|
+
FiatExchange = 'fiat_exchange',
|
|
14
|
+
InternalTransfer = 'internal_transfer',
|
|
15
|
+
Orders = 'orders',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface TariffGrid {
|
|
19
|
+
tariff_name?: string | null;
|
|
20
|
+
tariff_type?: TariffsGridTypeEnum | null;
|
|
21
|
+
commission?: string | null;
|
|
22
|
+
trading_volume?: number | null;
|
|
23
|
+
is_kyc_required?: boolean | null;
|
|
24
|
+
id?: string;
|
|
25
|
+
created_date?: string;
|
|
26
|
+
creator_id?: number | null;
|
|
27
|
+
modification_date?: string | null;
|
|
28
|
+
modifier_id?: number | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface ProfileResponse {
|
|
32
|
+
telegram_id?: string | null;
|
|
33
|
+
telegram_username?: string | null;
|
|
34
|
+
email?: string | null;
|
|
35
|
+
created_at: number;
|
|
36
|
+
is_active?: boolean | null;
|
|
37
|
+
balance_usdt?: string | null;
|
|
38
|
+
bonus_balance_usdt?: string | null;
|
|
39
|
+
kyc_status?: string | null;
|
|
40
|
+
kyc_link?: string | null;
|
|
41
|
+
is_wallet_commission?: boolean;
|
|
42
|
+
is_need_withdraw_kyc?: boolean;
|
|
43
|
+
tariff_grid?: TariffGrid | null;
|
|
44
|
+
tariff_grid_current?: TariffGrid | null;
|
|
45
|
+
is_partner_exchange_limit_free?: boolean | null;
|
|
46
|
+
last_login?: string | null;
|
|
47
|
+
is_tariff_autocalculate?: boolean | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
8
50
|
export interface IUseKeycloak {
|
|
9
51
|
login(email?: string, redirectUri?: string): void;
|
|
10
52
|
loginWithGoogle(redirectUri?: string): void;
|
|
@@ -19,6 +61,7 @@ export interface IUseKeycloak {
|
|
|
19
61
|
|
|
20
62
|
readonly isAuth: Ref<boolean>;
|
|
21
63
|
readonly checkAuth: Ref<boolean>;
|
|
64
|
+
readonly userData: Ref<ProfileResponse | null>;
|
|
22
65
|
readonly keycloak: Ref<Keycloak | null>;
|
|
23
66
|
readonly isInitialized: Ref<boolean>;
|
|
24
67
|
readonly keycloakUserData: Ref<Keycloak.KeycloakTokenParsed | null>;
|
|
@@ -32,6 +75,7 @@ const keycloak = ref<Keycloak | null>(null);
|
|
|
32
75
|
|
|
33
76
|
const isAuth = ref(false);
|
|
34
77
|
const checkAuth = ref(false);
|
|
78
|
+
const userData = ref<ProfileResponse | null>(null);
|
|
35
79
|
const keycloakUserData = ref<Keycloak.KeycloakTokenParsed | null>(null);
|
|
36
80
|
const locale = ref('en');
|
|
37
81
|
|
|
@@ -414,7 +458,8 @@ export async function initKeycloak() {
|
|
|
414
458
|
keycloakUserData.value = keycloak.value?.tokenParsed ?? null;
|
|
415
459
|
isAuth.value = true;
|
|
416
460
|
try {
|
|
417
|
-
postWebLogin();
|
|
461
|
+
await postWebLogin();
|
|
462
|
+
userData.value = await getPublicProfile();
|
|
418
463
|
} catch (e) { }
|
|
419
464
|
|
|
420
465
|
//setTimeout(() => {
|
|
@@ -429,7 +474,8 @@ export async function initKeycloak() {
|
|
|
429
474
|
keycloakUserData.value = keycloak.value?.tokenParsed ?? null;
|
|
430
475
|
isAuth.value = true;
|
|
431
476
|
try {
|
|
432
|
-
postWebLogin();
|
|
477
|
+
await postWebLogin();
|
|
478
|
+
userData.value = await getPublicProfile();
|
|
433
479
|
} catch { }
|
|
434
480
|
}
|
|
435
481
|
}
|
|
@@ -483,6 +529,7 @@ export const keycloakInit = (dontChangeRedirectUri?: Ref<boolean>, keycloakRedir
|
|
|
483
529
|
isInitialized: readonly(isInitialized),
|
|
484
530
|
isAuth: readonly(isAuth),
|
|
485
531
|
checkAuth: readonly(checkAuth),
|
|
532
|
+
userData: readonly(userData),
|
|
486
533
|
|
|
487
534
|
keycloakUserData,
|
|
488
535
|
|