cynx-lib 1.3.84 → 1.3.86
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/gen.js +77 -77
- package/package.json +5 -1
- package/ui/components/Drawer.jsx +208 -208
- package/ui/components/Pagination.jsx +145 -145
- package/ui/components/PrivacyBlur.jsx +603 -603
- package/utils/index.cjs +5 -0
- package/utils/index.js +22 -20
- package/utils/utils/duration.js +139 -139
- package/utils/utils/oidc.js +214 -214
- package/utils/utils/realtime.js +1634 -1634
- package/utils/utils/session.cjs +87 -9
- package/utils/utils/session.js +81 -8
- package/utils/utils/session_manager.cjs +490 -0
- package/utils/utils/session_manager.js +549 -0
- package/utils/utils/storage.js +393 -393
- package/utils/utils/ui.js +111 -111
- package/vue/components/Badge.vue +79 -79
- package/vue/components/Button.vue +209 -209
- package/vue/components/Checkbox.vue +103 -103
- package/vue/components/CircularProgress.vue +383 -383
- package/vue/components/Divider.vue +94 -94
- package/vue/components/Drawer.vue +243 -243
- package/vue/components/InfoBadge.vue +223 -223
- package/vue/components/Input.vue +341 -341
- package/vue/components/LinearProgress.vue +268 -268
- package/vue/components/Modal.vue +226 -226
- package/vue/components/Pagination.vue +199 -199
- package/vue/components/Select.vue +713 -713
- package/vue/components/Sidebar.vue +955 -955
- package/vue/components/Skeleton.vue +91 -91
- package/vue/components/Spinner.vue +263 -263
- package/vue/components/StatusTag.vue +89 -89
- package/vue/components/TabBar.vue +176 -176
- package/vue/components/Table.vue +388 -388
- package/vue/components/TimePicker.vue +399 -399
- package/vue/components/Toggle.vue +115 -115
- package/vue/components/XTable.vue +119 -119
- package/vue/composables/useAutoSkeletonRows.ts +71 -71
- package/vue/index.d.ts +67 -67
- package/vue/index.js +86 -86
package/utils/utils/session.cjs
CHANGED
|
@@ -17,12 +17,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var session_exports = {};
|
|
19
19
|
__export(session_exports, {
|
|
20
|
+
SessionManager: () => import_session_manager.SessionManager,
|
|
21
|
+
createSessionManager: () => import_session_manager.createSessionManager,
|
|
20
22
|
default: () => session_default,
|
|
21
23
|
deriveDeviceName: () => deriveDeviceName,
|
|
22
|
-
|
|
24
|
+
extractToken: () => import_session_manager.extractToken,
|
|
25
|
+
formatToken: () => import_session_manager.formatToken,
|
|
26
|
+
genSessionToken: () => genSessionToken,
|
|
27
|
+
getDeviceLabel: () => getDeviceLabel,
|
|
28
|
+
getSessionId: () => import_session_manager.getSessionId,
|
|
29
|
+
parseToken: () => import_session_manager.parseToken,
|
|
30
|
+
parseUserAgent: () => parseUserAgent
|
|
23
31
|
});
|
|
24
32
|
module.exports = __toCommonJS(session_exports);
|
|
25
33
|
var import_uid = require("./uid.cjs");
|
|
34
|
+
var import_session_manager = require("./session_manager.cjs");
|
|
26
35
|
function genSessionToken(byteLength = 32) {
|
|
27
36
|
const bytes = (0, import_uid.getRandomBytes)(byteLength);
|
|
28
37
|
let hex = "";
|
|
@@ -31,6 +40,71 @@ function genSessionToken(byteLength = 32) {
|
|
|
31
40
|
}
|
|
32
41
|
return `st_${hex}`;
|
|
33
42
|
}
|
|
43
|
+
function getDeviceLabel(ua) {
|
|
44
|
+
if (!ua) return "PC";
|
|
45
|
+
if (/windows phone/i.test(ua)) return "Windows Phone";
|
|
46
|
+
if (/windows nt 10\.0/i.test(ua)) return "Windows 10/11 PC";
|
|
47
|
+
if (/windows nt 6\.3/i.test(ua)) return "Windows 8.1 PC";
|
|
48
|
+
if (/windows nt 6\.1/i.test(ua)) return "Windows 7 PC";
|
|
49
|
+
if (/win64|win32|windows/i.test(ua)) return "Windows PC";
|
|
50
|
+
if (/ipad/i.test(ua)) return "iPad";
|
|
51
|
+
if (/iphone/i.test(ua)) return "iPhone";
|
|
52
|
+
if (/macintosh|mac os x/i.test(ua)) return "MacBook / Mac";
|
|
53
|
+
if (/android/i.test(ua)) return /mobile/i.test(ua) ? "Android Phone" : "Android Tablet";
|
|
54
|
+
if (/cros/i.test(ua)) return "Chromebook";
|
|
55
|
+
if (/linux/i.test(ua)) return "Linux PC";
|
|
56
|
+
return "Desktop PC";
|
|
57
|
+
}
|
|
58
|
+
function parseUserAgent(ua) {
|
|
59
|
+
if (!ua) return { browser: "Unknown", os: "Unknown", deviceType: "desktop" };
|
|
60
|
+
let os = "Unknown";
|
|
61
|
+
let browser = "Unknown";
|
|
62
|
+
let deviceType = "desktop";
|
|
63
|
+
if (/windows phone/i.test(ua)) {
|
|
64
|
+
os = "Windows Phone";
|
|
65
|
+
deviceType = "mobile";
|
|
66
|
+
} else if (/win64|win32|windows/i.test(ua)) {
|
|
67
|
+
os = "Windows";
|
|
68
|
+
deviceType = "desktop";
|
|
69
|
+
} else if (/ipad/i.test(ua)) {
|
|
70
|
+
os = "iPadOS";
|
|
71
|
+
deviceType = "tablet";
|
|
72
|
+
} else if (/iphone|ipod/i.test(ua)) {
|
|
73
|
+
os = "iOS";
|
|
74
|
+
deviceType = "mobile";
|
|
75
|
+
} else if (/android/i.test(ua)) {
|
|
76
|
+
os = "Android";
|
|
77
|
+
deviceType = /mobile/i.test(ua) ? "mobile" : "tablet";
|
|
78
|
+
} else if (/macintosh|mac os x/i.test(ua)) {
|
|
79
|
+
os = "macOS";
|
|
80
|
+
deviceType = "desktop";
|
|
81
|
+
} else if (/cros/i.test(ua)) {
|
|
82
|
+
os = "Chrome OS";
|
|
83
|
+
deviceType = "desktop";
|
|
84
|
+
} else if (/linux/i.test(ua)) {
|
|
85
|
+
os = "Linux";
|
|
86
|
+
deviceType = "desktop";
|
|
87
|
+
}
|
|
88
|
+
if (/edg\//i.test(ua)) {
|
|
89
|
+
const m = ua.match(/edg\/(\d+)/i);
|
|
90
|
+
browser = m ? `Edge ${m[1]}` : "Edge";
|
|
91
|
+
} else if (/opr\/|opera/i.test(ua)) {
|
|
92
|
+
const m = ua.match(/(?:opr|opera)\/(\d+)/i);
|
|
93
|
+
browser = m ? `Opera ${m[1]}` : "Opera";
|
|
94
|
+
} else if (/chrome|crios/i.test(ua)) {
|
|
95
|
+
const m = ua.match(/(?:chrome|crios)\/(\d+)/i);
|
|
96
|
+
browser = m ? `Chrome ${m[1]}` : "Chrome";
|
|
97
|
+
} else if (/firefox|fxios/i.test(ua)) {
|
|
98
|
+
const m = ua.match(/(?:firefox|fxios)\/(\d+)/i);
|
|
99
|
+
browser = m ? `Firefox ${m[1]}` : "Firefox";
|
|
100
|
+
} else if (/safari/i.test(ua) && !/chrome|crios/i.test(ua)) {
|
|
101
|
+
const m = ua.match(/version\/(\d+)/i);
|
|
102
|
+
browser = m ? `Safari ${m[1]}` : "Safari";
|
|
103
|
+
} else if (/postman/i.test(ua)) {
|
|
104
|
+
browser = "Postman API";
|
|
105
|
+
}
|
|
106
|
+
return { browser, os, deviceType };
|
|
107
|
+
}
|
|
34
108
|
function deriveDeviceName(req, userAgent = "") {
|
|
35
109
|
const headers = req?.headers || {};
|
|
36
110
|
const fromHeader = headers["x-device-name"] || headers["x-pc-name"] || headers["x-computer-name"] || "";
|
|
@@ -42,20 +116,24 @@ function deriveDeviceName(req, userAgent = "") {
|
|
|
42
116
|
return fromBody.trim().slice(0, 120);
|
|
43
117
|
}
|
|
44
118
|
const ua = userAgent || headers["user-agent"] || "";
|
|
45
|
-
|
|
46
|
-
if (/macintosh|mac os/i.test(ua)) return "Mac";
|
|
47
|
-
if (/iphone/i.test(ua)) return "iPhone";
|
|
48
|
-
if (/ipad/i.test(ua)) return "iPad";
|
|
49
|
-
if (/android/i.test(ua)) return "Android Device";
|
|
50
|
-
if (/linux/i.test(ua)) return "Linux PC";
|
|
51
|
-
return "Desktop PC";
|
|
119
|
+
return getDeviceLabel(ua);
|
|
52
120
|
}
|
|
53
121
|
var session_default = {
|
|
54
122
|
genSessionToken,
|
|
123
|
+
getDeviceLabel,
|
|
124
|
+
parseUserAgent,
|
|
55
125
|
deriveDeviceName
|
|
56
126
|
};
|
|
57
127
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
128
|
0 && (module.exports = {
|
|
129
|
+
SessionManager,
|
|
130
|
+
createSessionManager,
|
|
59
131
|
deriveDeviceName,
|
|
60
|
-
|
|
132
|
+
extractToken,
|
|
133
|
+
formatToken,
|
|
134
|
+
genSessionToken,
|
|
135
|
+
getDeviceLabel,
|
|
136
|
+
getSessionId,
|
|
137
|
+
parseToken,
|
|
138
|
+
parseUserAgent
|
|
61
139
|
});
|
package/utils/utils/session.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Helpers for generating secure session tokens and extracting human-friendly device names
|
|
5
5
|
* from request headers and user-agent strings.
|
|
6
|
+
*
|
|
7
|
+
* STRICT NO EMOJIS!
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
import { getRandomBytes } from './uid.js';
|
|
@@ -23,12 +25,78 @@ export function genSessionToken(byteLength = 32) {
|
|
|
23
25
|
return `st_${hex}`;
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Extract human-readable device label from User-Agent string.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} ua User-Agent string
|
|
32
|
+
* @returns {string} e.g. "Windows 10/11 PC", "MacBook / Mac", "iPhone", "Android Phone", "Linux PC"
|
|
33
|
+
*/
|
|
34
|
+
export function getDeviceLabel(ua) {
|
|
35
|
+
if (!ua) return 'PC';
|
|
36
|
+
if (/windows phone/i.test(ua)) return 'Windows Phone';
|
|
37
|
+
if (/windows nt 10\.0/i.test(ua)) return 'Windows 10/11 PC';
|
|
38
|
+
if (/windows nt 6\.3/i.test(ua)) return 'Windows 8.1 PC';
|
|
39
|
+
if (/windows nt 6\.1/i.test(ua)) return 'Windows 7 PC';
|
|
40
|
+
if (/win64|win32|windows/i.test(ua)) return 'Windows PC';
|
|
41
|
+
if (/ipad/i.test(ua)) return 'iPad';
|
|
42
|
+
if (/iphone/i.test(ua)) return 'iPhone';
|
|
43
|
+
if (/macintosh|mac os x/i.test(ua)) return 'MacBook / Mac';
|
|
44
|
+
if (/android/i.test(ua)) return /mobile/i.test(ua) ? 'Android Phone' : 'Android Tablet';
|
|
45
|
+
if (/cros/i.test(ua)) return 'Chromebook';
|
|
46
|
+
if (/linux/i.test(ua)) return 'Linux PC';
|
|
47
|
+
return 'Desktop PC';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Parse User-Agent string into browser, OS, and device type.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} ua User-Agent string
|
|
54
|
+
* @returns {{ browser: string, os: string, deviceType: 'desktop' | 'mobile' | 'tablet' }}
|
|
55
|
+
*/
|
|
56
|
+
export function parseUserAgent(ua) {
|
|
57
|
+
if (!ua) return { browser: 'Unknown', os: 'Unknown', deviceType: 'desktop' };
|
|
58
|
+
|
|
59
|
+
let os = 'Unknown';
|
|
60
|
+
let browser = 'Unknown';
|
|
61
|
+
let deviceType = 'desktop';
|
|
62
|
+
|
|
63
|
+
if (/windows phone/i.test(ua)) { os = 'Windows Phone'; deviceType = 'mobile'; }
|
|
64
|
+
else if (/win64|win32|windows/i.test(ua)) { os = 'Windows'; deviceType = 'desktop'; }
|
|
65
|
+
else if (/ipad/i.test(ua)) { os = 'iPadOS'; deviceType = 'tablet'; }
|
|
66
|
+
else if (/iphone|ipod/i.test(ua)) { os = 'iOS'; deviceType = 'mobile'; }
|
|
67
|
+
else if (/android/i.test(ua)) { os = 'Android'; deviceType = /mobile/i.test(ua) ? 'mobile' : 'tablet'; }
|
|
68
|
+
else if (/macintosh|mac os x/i.test(ua)) { os = 'macOS'; deviceType = 'desktop'; }
|
|
69
|
+
else if (/cros/i.test(ua)) { os = 'Chrome OS'; deviceType = 'desktop'; }
|
|
70
|
+
else if (/linux/i.test(ua)) { os = 'Linux'; deviceType = 'desktop'; }
|
|
71
|
+
|
|
72
|
+
if (/edg\//i.test(ua)) {
|
|
73
|
+
const m = ua.match(/edg\/(\d+)/i);
|
|
74
|
+
browser = m ? `Edge ${m[1]}` : 'Edge';
|
|
75
|
+
} else if (/opr\/|opera/i.test(ua)) {
|
|
76
|
+
const m = ua.match(/(?:opr|opera)\/(\d+)/i);
|
|
77
|
+
browser = m ? `Opera ${m[1]}` : 'Opera';
|
|
78
|
+
} else if (/chrome|crios/i.test(ua)) {
|
|
79
|
+
const m = ua.match(/(?:chrome|crios)\/(\d+)/i);
|
|
80
|
+
browser = m ? `Chrome ${m[1]}` : 'Chrome';
|
|
81
|
+
} else if (/firefox|fxios/i.test(ua)) {
|
|
82
|
+
const m = ua.match(/(?:firefox|fxios)\/(\d+)/i);
|
|
83
|
+
browser = m ? `Firefox ${m[1]}` : 'Firefox';
|
|
84
|
+
} else if (/safari/i.test(ua) && !/chrome|crios/i.test(ua)) {
|
|
85
|
+
const m = ua.match(/version\/(\d+)/i);
|
|
86
|
+
browser = m ? `Safari ${m[1]}` : 'Safari';
|
|
87
|
+
} else if (/postman/i.test(ua)) {
|
|
88
|
+
browser = 'Postman API';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return { browser, os, deviceType };
|
|
92
|
+
}
|
|
93
|
+
|
|
26
94
|
/**
|
|
27
95
|
* Derive human-readable device name from Express/Fastify request or User-Agent string.
|
|
28
96
|
*
|
|
29
97
|
* @param {object} [req] HTTP request object
|
|
30
98
|
* @param {string} [userAgent=''] User-Agent string
|
|
31
|
-
* @returns {string} e.g. "Windows PC", "Mac", "iPhone", "Android
|
|
99
|
+
* @returns {string} e.g. "Windows 10/11 PC", "MacBook / Mac", "iPhone", "Android Phone", "Desktop PC"
|
|
32
100
|
*/
|
|
33
101
|
export function deriveDeviceName(req, userAgent = '') {
|
|
34
102
|
const headers = req?.headers || {};
|
|
@@ -43,16 +111,21 @@ export function deriveDeviceName(req, userAgent = '') {
|
|
|
43
111
|
}
|
|
44
112
|
|
|
45
113
|
const ua = userAgent || headers['user-agent'] || '';
|
|
46
|
-
|
|
47
|
-
if (/macintosh|mac os/i.test(ua)) return 'Mac';
|
|
48
|
-
if (/iphone/i.test(ua)) return 'iPhone';
|
|
49
|
-
if (/ipad/i.test(ua)) return 'iPad';
|
|
50
|
-
if (/android/i.test(ua)) return 'Android Device';
|
|
51
|
-
if (/linux/i.test(ua)) return 'Linux PC';
|
|
52
|
-
return 'Desktop PC';
|
|
114
|
+
return getDeviceLabel(ua);
|
|
53
115
|
}
|
|
54
116
|
|
|
117
|
+
export {
|
|
118
|
+
formatToken,
|
|
119
|
+
parseToken,
|
|
120
|
+
getSessionId,
|
|
121
|
+
extractToken,
|
|
122
|
+
SessionManager,
|
|
123
|
+
createSessionManager,
|
|
124
|
+
} from './session_manager.js';
|
|
125
|
+
|
|
55
126
|
export default {
|
|
56
127
|
genSessionToken,
|
|
128
|
+
getDeviceLabel,
|
|
129
|
+
parseUserAgent,
|
|
57
130
|
deriveDeviceName,
|
|
58
131
|
};
|