cynx-lib 1.3.80 → 1.3.82
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 +1 -1
- package/ui/components/Drawer.jsx +208 -208
- package/ui/components/Layout.jsx +138 -138
- package/ui/components/LoginPage.jsx +405 -405
- package/ui/components/Pagination.jsx +145 -145
- package/ui/components/PrivacyBlur.jsx +603 -603
- package/ui/components/Sidebar.jsx +820 -820
- package/utils/index.js +20 -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.js +58 -58
- package/utils/utils/storage.js +393 -393
- package/utils/utils/storage_manager.cjs +84 -7
- package/utils/utils/storage_manager.js +95 -8
- 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.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* cynx/utils — Session and Device Resolution Utilities (session.js)
|
|
3
|
-
*
|
|
4
|
-
* Helpers for generating secure session tokens and extracting human-friendly device names
|
|
5
|
-
* from request headers and user-agent strings.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { getRandomBytes } from './uid.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Generate a cryptographically secure random session token.
|
|
12
|
-
* Example: "st_9b1deb4d3b7d4bad9bdd2b0d7b3dcb6d..."
|
|
13
|
-
*
|
|
14
|
-
* @param {number} [byteLength=32]
|
|
15
|
-
* @returns {string}
|
|
16
|
-
*/
|
|
17
|
-
export function genSessionToken(byteLength = 32) {
|
|
18
|
-
const bytes = getRandomBytes(byteLength);
|
|
19
|
-
let hex = '';
|
|
20
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
21
|
-
hex += bytes[i].toString(16).padStart(2, '0');
|
|
22
|
-
}
|
|
23
|
-
return `st_${hex}`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Derive human-readable device name from Express/Fastify request or User-Agent string.
|
|
28
|
-
*
|
|
29
|
-
* @param {object} [req] HTTP request object
|
|
30
|
-
* @param {string} [userAgent=''] User-Agent string
|
|
31
|
-
* @returns {string} e.g. "Windows PC", "Mac", "iPhone", "Android Device", "Desktop PC"
|
|
32
|
-
*/
|
|
33
|
-
export function deriveDeviceName(req, userAgent = '') {
|
|
34
|
-
const headers = req?.headers || {};
|
|
35
|
-
const fromHeader = headers['x-device-name'] || headers['x-pc-name'] || headers['x-computer-name'] || '';
|
|
36
|
-
if (typeof fromHeader === 'string' && fromHeader.trim()) {
|
|
37
|
-
return fromHeader.trim().slice(0, 120);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const fromBody = req?.body?.deviceName || req?.body?.device_name || req?.body?.pcName || req?.body?.pc_name;
|
|
41
|
-
if (typeof fromBody === 'string' && fromBody.trim()) {
|
|
42
|
-
return fromBody.trim().slice(0, 120);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const ua = userAgent || headers['user-agent'] || '';
|
|
46
|
-
if (/windows/i.test(ua)) return 'Windows PC';
|
|
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';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default {
|
|
56
|
-
genSessionToken,
|
|
57
|
-
deriveDeviceName,
|
|
58
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* cynx/utils — Session and Device Resolution Utilities (session.js)
|
|
3
|
+
*
|
|
4
|
+
* Helpers for generating secure session tokens and extracting human-friendly device names
|
|
5
|
+
* from request headers and user-agent strings.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { getRandomBytes } from './uid.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generate a cryptographically secure random session token.
|
|
12
|
+
* Example: "st_9b1deb4d3b7d4bad9bdd2b0d7b3dcb6d..."
|
|
13
|
+
*
|
|
14
|
+
* @param {number} [byteLength=32]
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
17
|
+
export function genSessionToken(byteLength = 32) {
|
|
18
|
+
const bytes = getRandomBytes(byteLength);
|
|
19
|
+
let hex = '';
|
|
20
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
21
|
+
hex += bytes[i].toString(16).padStart(2, '0');
|
|
22
|
+
}
|
|
23
|
+
return `st_${hex}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Derive human-readable device name from Express/Fastify request or User-Agent string.
|
|
28
|
+
*
|
|
29
|
+
* @param {object} [req] HTTP request object
|
|
30
|
+
* @param {string} [userAgent=''] User-Agent string
|
|
31
|
+
* @returns {string} e.g. "Windows PC", "Mac", "iPhone", "Android Device", "Desktop PC"
|
|
32
|
+
*/
|
|
33
|
+
export function deriveDeviceName(req, userAgent = '') {
|
|
34
|
+
const headers = req?.headers || {};
|
|
35
|
+
const fromHeader = headers['x-device-name'] || headers['x-pc-name'] || headers['x-computer-name'] || '';
|
|
36
|
+
if (typeof fromHeader === 'string' && fromHeader.trim()) {
|
|
37
|
+
return fromHeader.trim().slice(0, 120);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const fromBody = req?.body?.deviceName || req?.body?.device_name || req?.body?.pcName || req?.body?.pc_name;
|
|
41
|
+
if (typeof fromBody === 'string' && fromBody.trim()) {
|
|
42
|
+
return fromBody.trim().slice(0, 120);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const ua = userAgent || headers['user-agent'] || '';
|
|
46
|
+
if (/windows/i.test(ua)) return 'Windows PC';
|
|
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';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
genSessionToken,
|
|
57
|
+
deriveDeviceName,
|
|
58
|
+
};
|