@qlibs/utils 1.7.4 → 1.7.5
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/dist/utils/axios.d.ts +4 -4
- package/dist/utils/axios.js +17 -5
- package/dist/utils/browser.d.ts +2 -0
- package/dist/utils/browser.js +16 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +3 -1
package/dist/utils/axios.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
2
2
|
export declare function injectAxiosInstance(axiosInstance: AxiosInstance, headers: 'application/json' | 'multipart/form-data' | string | {
|
3
3
|
contentType: 'application/json' | 'multipart/form-data' | string;
|
4
|
-
'
|
5
|
-
'
|
6
|
-
'
|
7
|
-
'
|
4
|
+
'X-Platform'?: 'cms' | 'web' | 'mobile';
|
5
|
+
'X-Device-Id': string;
|
6
|
+
'X-Device-Name': string;
|
7
|
+
'X-App-Version': string;
|
8
8
|
}, Modal: any): AxiosInstance;
|
package/dist/utils/axios.js
CHANGED
@@ -2,13 +2,25 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.injectAxiosInstance = injectAxiosInstance;
|
4
4
|
const auth_1 = require("./auth");
|
5
|
+
const browser_1 = require("./browser");
|
5
6
|
function injectAxiosInstance(axiosInstance, headers, Modal) {
|
6
7
|
axiosInstance.interceptors.request.use(async (config) => {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
if (typeof headers === 'object') {
|
9
|
+
config.headers['Content-Type'] =
|
10
|
+
headers.contentType || 'application/json';
|
11
|
+
config.headers['X-Platform'] = headers['X-Platform'] || 'cms';
|
12
|
+
config.headers['X-Device-Id'] = headers['X-Device-Id'];
|
13
|
+
config.headers['X-Device-Name'] = headers['X-Device-Name'];
|
14
|
+
config.headers['X-App-Version'] = headers['X-App-Version'];
|
15
|
+
}
|
16
|
+
else {
|
17
|
+
config.headers['Content-Type'] =
|
18
|
+
headers || 'application/json';
|
19
|
+
config.headers['X-Platform'] = 'cms';
|
20
|
+
config.headers['X-Device-Id'] = (0, browser_1.getBrowserId)();
|
21
|
+
config.headers['X-Device-Name'] = (0, browser_1.getBrowserName)();
|
22
|
+
config.headers['X-App-Version'] = '0.0.0';
|
23
|
+
}
|
12
24
|
config.headers['Authorization'] = 'Bearer ' + (0, auth_1.getToken)();
|
13
25
|
return config;
|
14
26
|
}, (error) => {
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.getBrowserName = getBrowserName;
|
7
|
+
exports.getBrowserId = getBrowserId;
|
8
|
+
const ets_fingerprintjs_1 = require("ets-fingerprintjs");
|
9
|
+
const bowser_1 = __importDefault(require("bowser"));
|
10
|
+
function getBrowserName() {
|
11
|
+
const browser = bowser_1.default.getParser(window.navigator.userAgent);
|
12
|
+
return `${browser.getBrowserName()} ${browser.getBrowserVersion()} on ${browser.getOSName()} ${browser.getOSVersion()}`;
|
13
|
+
}
|
14
|
+
function getBrowserId() {
|
15
|
+
return ets_fingerprintjs_1.uid.toString();
|
16
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@qlibs/utils",
|
3
|
-
"version": "1.7.
|
3
|
+
"version": "1.7.5",
|
4
4
|
"description": "",
|
5
5
|
"author": "QBIT Developer",
|
6
6
|
"license": "MIT",
|
@@ -26,6 +26,8 @@
|
|
26
26
|
},
|
27
27
|
"dependencies": {
|
28
28
|
"axios": "^1.7.9",
|
29
|
+
"bowser": "^2.11.0",
|
30
|
+
"ets-fingerprintjs": "^1.8.0",
|
29
31
|
"husky": "^8.0.3",
|
30
32
|
"image-blob-reduce": "^4.1.0",
|
31
33
|
"immutability-helper": "^3.1.1",
|