@alfabit/keycloak 0.0.1

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/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Установка
2
+
3
+ ```
4
+ yarn add https://gitlab+deploy-token-7519636:gldt-UVfbjqZ3Ks3KLzvpPDPT@gitlab.com/AlfaBit.Group/ui/alfabit-common-components.git
5
+ ```
6
+
7
+ # Обновление компонентов
8
+
9
+ Добавить в package.json в scripts
10
+
11
+ ```
12
+ "get:templates": "node ./node_modules/alfabit-common-components/scripts/get-templates.js",
13
+ "upgrade:alfabit-common-components": "yarn upgrade alfabit-common-components && yarn get:templates"
14
+ ```
15
+
16
+ ## Для обновления компонента и шаблонов команда
17
+
18
+ ```
19
+ yarn upgrade:alfabit-common-components
20
+ ```
21
+
22
+ # Принудительно обновить пакет
23
+
24
+ ```
25
+ yarn upgrade alfabit-common-components
26
+ ```
27
+
28
+ # Импорт стилей
29
+
30
+ ## Для quasar
31
+
32
+ можно создать файл add.scss, добавить строку
33
+
34
+ ```
35
+ @import "alfabit-common-components/output/index.css";
36
+ ```
37
+
38
+ подключить шрифт Inter (при необходимости)
39
+
40
+ ```
41
+ @import "alfabit-common-components/src/fonts.css";
42
+ ```
43
+
44
+ и добавить в секцию css: в файле quasar.config.ts
45
+
46
+ или просто добавить в любой файл scss или vue импорт (в файл vue не желательно добавлять, т.к. сколько раз будет подключаться компонент, столько раз будут добавляться стили)
47
+
48
+ ```
49
+ @import "alfabit-common-components/output/index.css";
50
+ ```
51
+
52
+ желательно, чтобы этот файл импортировался перед основными стилями, чтобы можно было переопределить переменные css и стили.
53
+
54
+ # Обновить в npm
55
+
56
+ yarn publish
57
+
58
+ # Обновить пакет
59
+
60
+ yarn upgrade alfabit-common-components --latest
61
+
62
+ npm version patch && npm publish
63
+
64
+ # Собрать стили для компонентов src/components/exchange
65
+
66
+ sass src/components/exchange/main.scss build/exchange/css/main.css --style compressed --no-source-map
67
+
68
+ # Собрать стили для компонентов src/components/header-footer
69
+
70
+ sass src/components/header-footer/scss/index.scss build/header-footer/css/main.css --style=compressed --no-source-map
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@alfabit/keycloak",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "license": "UNLICENSED",
7
+ "main": "src/index.ts",
8
+ "style": "output/index.css",
9
+ "files": [
10
+ "output/*",
11
+ "build/*",
12
+ "src/*",
13
+ "scripts/*",
14
+ "tsconfig.app.json",
15
+ "tsconfig.json",
16
+ "tsconfig.node.json",
17
+ "vite.config.ts",
18
+ "yarn.lock"
19
+ ],
20
+ "scripts": {
21
+ "pub": "yarn styles:header-footer && npm publish",
22
+ "build": "vue-tsc -b && vite build",
23
+ "upgrade:alfabit-constants": "yarn upgrade @alfabit/constants --latest"
24
+ },
25
+ "devDependencies": {
26
+ "@alfabit/constants": "^0.0.3",
27
+ "@intlify/unplugin-vue-i18n": "^6.0.8",
28
+ "@tanstack/vue-query": "^5.72.0",
29
+ "@types/lodash-es": "^4.17.12",
30
+ "@types/node": "^24.0.7",
31
+ "@vitejs/plugin-vue": "^5.2.1",
32
+ "@vue/tsconfig": "^0.7.0",
33
+ "decimal.js": "^10.5.0",
34
+ "keycloak-js": "^26.2.0",
35
+ "lodash-es": "^4.17.21",
36
+ "node-fetch": "^3.3.2",
37
+ "sass-embedded": "^1.87.0",
38
+ "typescript": "~5.7.2",
39
+ "vite": "^6.2.0",
40
+ "vue": "^3.5.13",
41
+ "vue-collapsed": "^1.3.4",
42
+ "vue-i18n": "^12.0.0-alpha.2",
43
+ "vue-router": "4",
44
+ "vue-tsc": "^2.2.10"
45
+ },
46
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
47
+ }
@@ -0,0 +1,50 @@
1
+ import { WALLET_API_HOST } from '@alfabit/constants';
2
+ import { Api } from './swagger-types';
3
+ import { getToken } from '../../composables';
4
+
5
+ const client = new Api({
6
+ baseUrl: WALLET_API_HOST,
7
+ });
8
+
9
+ export const getBearerToken = () => {
10
+ const token = getToken();
11
+ return token ? `Bearer ${token}` : '';
12
+ };
13
+
14
+ const api = client.public;
15
+
16
+ type ApiMethod = (...args: any[]) => Promise<any>;
17
+
18
+ // Подмешаем токен в заголовок каждого запроса
19
+ Object.keys(client.public).forEach((methodName) => {
20
+ const nativeMethod = client.public[methodName as keyof typeof client.public] as ApiMethod;
21
+ const argsNumber = nativeMethod.length;
22
+
23
+ api[methodName as keyof typeof api] = function (...args: any[]) {
24
+ let params: Record<string, unknown> = {};
25
+
26
+ if (args.length > argsNumber) {
27
+ params = args.pop();
28
+ }
29
+
30
+ if (typeof params !== 'object' || params === null) {
31
+ params = {};
32
+ }
33
+
34
+ if (!('headers' in params)) {
35
+ params.headers = {};
36
+ }
37
+
38
+ const headers = {
39
+ ...((params.headers as Record<string, string>) ?? {}),
40
+ Authorization: getBearerToken(),
41
+ };
42
+
43
+ return nativeMethod(...args, {
44
+ ...params,
45
+ headers,
46
+ });
47
+ } as ApiMethod;
48
+ });
49
+
50
+ export default client;
@@ -0,0 +1 @@
1
+ export * from './public';
@@ -0,0 +1 @@
1
+ export * from './public';
@@ -0,0 +1 @@
1
+ export * from './post.web-login';
@@ -0,0 +1,12 @@
1
+ import { REF_KEY } from '@alfabit/constants';
2
+ import api from '../../../client';
3
+
4
+ export const postWebLogin = async () => {
5
+ if (typeof window === 'undefined') return;
6
+ const referral_token = localStorage.getItem(REF_KEY) ?? null;
7
+ const { data: data_1 } = await api.public.loginPublicWebLoginPost({
8
+ referral_token,
9
+ });
10
+ if (referral_token) localStorage.removeItem(REF_KEY);
11
+ return data_1;
12
+ };