isite 2024.8.3 → 2024.8.6

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.
Files changed (133) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1384 -1387
  3. package/apps/charts/site_files/html/PieChart.html +35 -35
  4. package/apps/charts/site_files/html/PieChart2.html +35 -35
  5. package/apps/charts/site_files/html/XYChart.html +42 -42
  6. package/apps/charts/site_files/html/column.html +60 -60
  7. package/apps/charts/site_files/html/gauge.html +44 -44
  8. package/apps/charts/site_files/html/index.html +92 -92
  9. package/apps/charts/site_files/html/line-graph.html +42 -42
  10. package/apps/charts/site_files/html/pie-chart-rounded-corners.html +38 -38
  11. package/apps/charts/site_files/html/simple-3D-pie-chart.html +43 -43
  12. package/apps/charts/site_files/js/chart-animated.js +2 -2
  13. package/apps/charts/site_files/json/PieChart.json +41 -41
  14. package/apps/charts/site_files/json/PieChart2.json +23 -23
  15. package/apps/charts/site_files/json/XYChart.json +74 -74
  16. package/apps/charts/site_files/json/bar-chart.json +99 -99
  17. package/apps/charts/site_files/json/column-chart.json +80 -80
  18. package/apps/charts/site_files/json/gauge.json +36 -36
  19. package/apps/charts/site_files/json/line-graph.json +1867 -1867
  20. package/apps/charts/site_files/json/pie-chart-rounded-corners.json +42 -42
  21. package/apps/charts/site_files/json/simple-3D-pie-chart.json +50 -50
  22. package/apps/client-side/package-lock.json +5 -5
  23. package/apps/client-side/package.json +21 -21
  24. package/apps/client-side/site_files/css/bootstrap3.css +5 -5
  25. package/apps/client-side/site_files/css/bootstrap4.css +6 -6
  26. package/apps/client-side/site_files/css/bootstrap5.css +6 -6
  27. package/apps/client-side/site_files/css/checkbox.css +125 -125
  28. package/apps/client-side/site_files/css/font-awesome.css +4616 -4616
  29. package/apps/client-side/site_files/css/font-awesome.min.css +4 -4
  30. package/apps/client-side/site_files/css/fonts.css +85 -85
  31. package/apps/client-side/site_files/css/help.css +51 -51
  32. package/apps/client-side/site_files/css/main-menu.css +66 -66
  33. package/apps/client-side/site_files/css/print.css +144 -144
  34. package/apps/client-side/site_files/css/prism.css +139 -139
  35. package/apps/client-side/site_files/css/progress.css +7 -7
  36. package/apps/client-side/site_files/css/radio.css +103 -103
  37. package/apps/client-side/site_files/css/scrollbar.css +13 -13
  38. package/apps/client-side/site_files/css/semantic.css +363 -363
  39. package/apps/client-side/site_files/css/table.css +87 -87
  40. package/apps/client-side/site_files/css/treeview.css +84 -84
  41. package/apps/client-side/site_files/css/ui.css +28 -28
  42. package/apps/client-side/site_files/css/video-js.min.css +1 -0
  43. package/apps/client-side/site_files/fonts/fontawesome-webfont.svg +2671 -2671
  44. package/apps/client-side/site_files/fonts/glyphicons-halflings-regular.svg +287 -287
  45. package/apps/client-side/site_files/fonts/icons.svg +684 -684
  46. package/apps/client-side/site_files/js/Youtube.min.js +1 -0
  47. package/apps/client-side/site_files/js/angular-animate.js +4179 -4179
  48. package/apps/client-side/site_files/js/angular.js +36599 -36599
  49. package/apps/client-side/site_files/js/angular.min.js +351 -351
  50. package/apps/client-side/site_files/js/angular.min.js.map +8 -8
  51. package/apps/client-side/site_files/js/barcode.js +1 -1
  52. package/apps/client-side/site_files/js/base64.js +319 -319
  53. package/apps/client-side/site_files/js/bootstrap-5-directive.js +1456 -1456
  54. package/apps/client-side/site_files/js/bootstrap3.js +6 -6
  55. package/apps/client-side/site_files/js/bootstrap4.js +6 -6
  56. package/apps/client-side/site_files/js/bootstrap5.js +6 -6
  57. package/apps/client-side/site_files/js/custom.js +149 -149
  58. package/apps/client-side/site_files/js/directive.min.js +1 -1
  59. package/apps/client-side/site_files/js/hijri.js +965 -965
  60. package/apps/client-side/site_files/js/jquery.js +2 -2
  61. package/apps/client-side/site_files/js/moment.js +4511 -4511
  62. package/apps/client-side/site_files/js/prism.js +6 -6
  63. package/apps/client-side/site_files/js/qrcode.js +1398 -1398
  64. package/apps/client-side/site_files/js/semantic.js +10 -10
  65. package/apps/client-side/site_files/js/video.min.js +53 -0
  66. package/apps/client-side/site_files/js/xlsx.js +23 -23
  67. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/brand-icons.svg +1008 -1008
  68. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/icons.svg +1518 -1518
  69. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/outline-icons.svg +366 -366
  70. package/apps/client-side/site_files/webfonts/fa-brands-400.svg +3717 -3717
  71. package/apps/client-side/site_files/webfonts/fa-regular-400.svg +801 -801
  72. package/apps/client-side/site_files/webfonts/fa-solid-900.svg +5034 -5034
  73. package/apps/security/README.md +12 -12
  74. package/apps/security/app.js +288 -288
  75. package/apps/security/libs/notifications.js +89 -89
  76. package/apps/security/site_files/html/add_modal.html +36 -36
  77. package/apps/security/site_files/html/content.html +36 -36
  78. package/apps/security/site_files/html/delete_modal.html +31 -31
  79. package/apps/security/site_files/html/head.html +7 -7
  80. package/apps/security/site_files/html/index.html +80 -80
  81. package/apps/security/site_files/html/login_modal.html +24 -24
  82. package/apps/security/site_files/html/logout_modal.html +21 -21
  83. package/apps/security/site_files/html/navbar.html +8 -8
  84. package/apps/security/site_files/html/register_modal.html +32 -32
  85. package/apps/security/site_files/html/update_modal.html +28 -28
  86. package/apps/security/site_files/html/view.html +74 -74
  87. package/apps/security/site_files/html/view_modal.html +32 -32
  88. package/apps/security/site_files/js/app.js +1 -1
  89. package/apps/security/site_files/js/index.js +278 -278
  90. package/apps/security/site_files/js/login.js +35 -35
  91. package/apps/security/site_files/js/logout.js +22 -22
  92. package/apps/security/site_files/js/navbar.js +26 -26
  93. package/apps/security/site_files/js/register.js +30 -30
  94. package/apps/security/site_files/json/permissions.json +7 -7
  95. package/apps/security/site_files/json/roles.json +33 -33
  96. package/apps/security/site_files/json/words.json +28 -28
  97. package/gulpfile.js +17 -17
  98. package/index.js +1 -1
  99. package/isite.postman_collection.json +7 -7
  100. package/isite_files/css/bootstrap.css +5 -5
  101. package/isite_files/css/font-awesome.css +4 -4
  102. package/isite_files/css/prism.css +139 -139
  103. package/isite_files/fonts/fontawesome-webfont.svg +2671 -2671
  104. package/isite_files/fonts/glyphicons-halflings-regular.svg +287 -287
  105. package/isite_files/html/files.html +9 -9
  106. package/isite_files/html/head.html +12 -12
  107. package/isite_files/html/index.html +30 -30
  108. package/isite_files/html/installing.html +27 -27
  109. package/isite_files/html/navbar.html +51 -51
  110. package/isite_files/html/routes.html +13 -13
  111. package/isite_files/html/sessions.html +13 -13
  112. package/isite_files/html/vars.html +9 -9
  113. package/isite_files/js/angular.js +334 -334
  114. package/isite_files/js/bootstrap.js +6 -6
  115. package/isite_files/js/custom.js +149 -149
  116. package/isite_files/js/jquery.js +4 -4
  117. package/isite_files/js/prism.js +6 -6
  118. package/lib/README.md +1 -1
  119. package/lib/collection.js +111 -17
  120. package/lib/cookie.js +81 -81
  121. package/lib/dashboard.js +189 -189
  122. package/lib/eval.js +48 -0
  123. package/lib/mongodb.js +819 -686
  124. package/lib/parser.js +910 -910
  125. package/lib/security.js +61 -61
  126. package/lib/session.js +153 -158
  127. package/lib/sessions.js +14 -30
  128. package/lib/ws.js +2 -2
  129. package/object-options/index.js +3 -3
  130. package/object-options/lib/fn.js +1 -1
  131. package/object-options/lib/isite.code-workspace +10 -10
  132. package/package.json +58 -55
  133. package/ssl/create_ssl.sh +3 -3
package/lib/security.js CHANGED
@@ -9,26 +9,25 @@ module.exports = function init(____0) {
9
9
  db: ____0.options.security.db,
10
10
  });
11
11
 
12
- /** Email Must Not Duplicate */
13
- ____0.$users.deleteDuplicate(
14
- {
15
- email: 1,
16
- },
17
- (err, result) => {
18
- ____0.$users.createUnique({
19
- email: 1,
20
- });
21
- }
22
- );
12
+ /** Email Must Not Duplicate but can be null */
13
+
14
+ ____0.$users.dropIndexes(() => {
15
+ ____0.$users.createIndex({ email: 1 }, { unique: true, partialFilterExpression: { email: { $exists: true } } }, () => {});
16
+ ____0.$users.createIndex({ username: 1 }, { unique: true, partialFilterExpression: { username: { $exists: true } } }, () => {});
17
+ ____0.$users.createIndex({ mobile: 1 }, { unique: true, partialFilterExpression: { mobile: { $exists: true } } }, () => {});
18
+ });
23
19
 
24
20
  ____0.$roles.deleteDuplicate(
25
21
  {
26
22
  name: 1,
27
23
  },
28
24
  (err, result) => {
29
- ____0.$roles.createUnique({
30
- name: 1,
31
- });
25
+ ____0.$roles.createUnique(
26
+ {
27
+ name: 1,
28
+ },
29
+ () => {}
30
+ );
32
31
  }
33
32
  );
34
33
 
@@ -387,39 +386,37 @@ module.exports = function init(____0) {
387
386
  });
388
387
  };
389
388
 
390
- security.getUser = function (userArgs, callback) {
389
+ security.getUser = function (_user, callback) {
391
390
  callback = callback || function () {};
392
- for (let i = 0; i < security.users.length; i++) {
393
- let user = security.users[i];
394
-
395
- if (
396
- (userArgs.id && user.id === userArgs.id) ||
397
- (!user.key && userArgs.email && user.email === userArgs.email.trim().toLowerCase()) ||
398
- (!user.key && userArgs.userName && user.userName === userArgs.userName.trim().toLowerCase()) ||
399
- (!user.key && userArgs.mobile && user.mobile === userArgs.mobile.trim().toLowerCase()) ||
400
- (user.key && userArgs.key && user.key === userArgs.key) ||
401
- (user.key && userArgs.email && user.key === ____0.x0md50x(userArgs.email.trim().toLowerCase()))
402
- ) {
403
- user.$memory = !0;
404
- user = security.handleUser(user);
405
- callback(null, user);
406
- return;
407
- }
408
- }
409
-
410
- ____0.$users.findOne(
411
- {
412
- where: userArgs,
413
- select: {},
414
- },
415
- function (err, doc) {
416
- if (doc && (userArgs.id || userArgs.email)) {
417
- doc = security.handleUser(doc);
418
- security.users.push(doc);
419
- }
420
- callback(err, doc);
421
- }
391
+ let index = security.users.findIndex(
392
+ (user) =>
393
+ (_user.id && user.id === _user.id) ||
394
+ (!user.key && _user.email && user.email === _user.email.trim().toLowerCase()) ||
395
+ (!user.key && _user.username && user.username === _user.username.trim().toLowerCase()) ||
396
+ (!user.key && _user.mobile && user.mobile === _user.mobile.trim().toLowerCase()) ||
397
+ (user.key && _user.key && user.key === _user.key) ||
398
+ (user.key && _user.email && user.key === ____0.x0md50x(_user.email.trim().toLowerCase()))
422
399
  );
400
+ if (index !== -1) {
401
+ security.users[index].$memory = !0;
402
+ security.users[index] = security.handleUser(security.users[index]);
403
+ callback(null, security.users[index]);
404
+ return;
405
+ } else {
406
+ ____0.$users.findOne(
407
+ {
408
+ where: _user,
409
+ select: {},
410
+ },
411
+ function (err, doc) {
412
+ if (!err && doc) {
413
+ doc = security.handleUser(doc);
414
+ security.users.push(doc);
415
+ }
416
+ callback(err, doc);
417
+ }
418
+ );
419
+ }
423
420
  };
424
421
 
425
422
  security.isUserExists = function (user, callback) {
@@ -474,8 +471,8 @@ module.exports = function init(____0) {
474
471
  user.email = user.email.trim().toLowerCase();
475
472
  } else if (user && user.mobile && user.password) {
476
473
  user.mobile = user.mobile.trim().toLowerCase();
477
- } else if (user && user.userName && user.password) {
478
- user.userName = user.userName.trim().toLowerCase();
474
+ } else if (user && user.username && user.password) {
475
+ user.username = user.username.trim().toLowerCase();
479
476
  } else {
480
477
  callback({
481
478
  message: 'User Info Not Correct',
@@ -488,7 +485,7 @@ module.exports = function init(____0) {
488
485
  if (
489
486
  (!_user.key && user.email && _user.email === user.email && _user.password === user.password) ||
490
487
  (!_user.key && user.mobile && _user.mobile === user.mobile && _user.password === user.password) ||
491
- (!_user.key && user.userName && _user.userName === user.userName && _user.password === user.password) ||
488
+ (!_user.key && user.username && _user.username === user.username && _user.password === user.password) ||
492
489
  (_user.key && user.key && _user.key === user.key) ||
493
490
  (_user.key && user.email && user.password && _user.key === ____0.x0md50x(user.email + user.password))
494
491
  ) {
@@ -517,8 +514,8 @@ module.exports = function init(____0) {
517
514
  where.email = user.email;
518
515
  } else if (user.mobile) {
519
516
  where.mobile = user.mobile;
520
- } else if (user.userName) {
521
- where.userName = user.userName;
517
+ } else if (user.username) {
518
+ where.username = user.username;
522
519
  } else {
523
520
  callback({
524
521
  message: 'User Info Not Correct',
@@ -579,8 +576,8 @@ module.exports = function init(____0) {
579
576
  user.email = user.email.trim().toLowerCase();
580
577
  } else if (user && user.mobile && user.password) {
581
578
  user.mobile = user.mobile.trim().toLowerCase();
582
- } else if (user && user.userName && user.password) {
583
- user.userName = user.userName.trim().toLowerCase();
579
+ } else if (user && user.username && user.password) {
580
+ user.username = user.username.trim().toLowerCase();
584
581
  } else {
585
582
  callback({
586
583
  message: 'User Info Not Correct',
@@ -645,7 +642,11 @@ module.exports = function init(____0) {
645
642
  });
646
643
  }
647
644
 
648
- res.cookie('access_token', ____0.x0md50x(new Date().getTime().toString() + '_' + Math.random() * (10000 - 1000) + 1000));
645
+ delete req.session.user;
646
+ req.session.accessToken = req.host + new Date().getTime().toString() + '_' + Math.random();
647
+ req.session.accessToken = ____0.x0md50x(req.session.accessToken);
648
+ res.set('Access-Token', req.session.accessToken);
649
+ res.cookie('access_token', req.session.accessToken);
649
650
  callback(null, !0);
650
651
  };
651
652
 
@@ -662,8 +663,8 @@ module.exports = function init(____0) {
662
663
  user.email = user.email.trim().toLowerCase();
663
664
  } else if (user && user.mobile && user.password) {
664
665
  user.mobile = user.mobile.trim().toLowerCase();
665
- } else if (user && user.userName && user.password) {
666
- user.userName = user.userName.trim().toLowerCase();
666
+ } else if (user && user.username && user.password) {
667
+ user.username = user.username.trim().toLowerCase();
667
668
  } else {
668
669
  callback({
669
670
  message: 'User Info Not Correct',
@@ -672,7 +673,7 @@ module.exports = function init(____0) {
672
673
  }
673
674
 
674
675
  if (!user.email) {
675
- user.email = user.userName || user.mobile || 'Not Set';
676
+ user.email = user.username || user.mobile || 'Not Set';
676
677
  }
677
678
 
678
679
  security.isUserExists(user, function (err, u) {
@@ -731,8 +732,8 @@ module.exports = function init(____0) {
731
732
  where.email = user.email.trim().toLowerCase();
732
733
  } else if (user.mobile) {
733
734
  where.mobile = user.mobile.trim().toLowerCase();
734
- } else if (user.userName) {
735
- where.userName = user.userName.trim().toLowerCase();
735
+ } else if (user.username) {
736
+ where.username = user.username.trim().toLowerCase();
736
737
  } else {
737
738
  callback({
738
739
  message: 'User Info Not Correct',
@@ -1038,12 +1039,11 @@ module.exports = function init(____0) {
1038
1039
  });
1039
1040
 
1040
1041
  ____0.post('/x-security/api/user/logout', function (req, res) {
1041
- let response = {
1042
- accessToken: req.session.accessToken,
1043
- };
1042
+ let response = {};
1044
1043
 
1045
1044
  ____0.security.logout(req, res, () => {
1046
1045
  response.done = !0;
1046
+ response.accessToken = req.session.accessToken;
1047
1047
  res.json(response);
1048
1048
  });
1049
1049
  });
package/lib/session.js CHANGED
@@ -1,158 +1,153 @@
1
- module.exports = function init(req, res, ____0, callback) {
2
- ____0.getSession({ accessToken: req.cookie('access_token') || req.headers['Access-Token'] || req.headers['access-token'] || req.query['access-token'] }, (session) => {
3
- if (!session.accessToken) {
4
- session.accessToken = new Date().getTime().toString() + '_' + Math.random() * (10000 - 1000) + 1000;
5
- session.accessToken = ____0.x0md50x(session.accessToken);
6
- res.cookie('access_token', session.accessToken);
7
- res.set('Access-Token', session.accessToken);
8
- }
9
- if (req.query['access-token']) {
10
- res.cookie('access_token', session.accessToken);
11
- res.set('Access-Token', session.accessToken);
12
- }
13
-
14
- session.ip = req.ip;
15
- session.modifiedTime = new Date().getTime();
16
- ____0.saveSession(session);
17
-
18
- function AssignFeatures() {
19
- ____0.options.defaults.features.forEach((f) => {
20
- req.features.push(f);
21
- });
22
- ____0.features.forEach((f) => {
23
- req.features.push(f.name);
24
- });
25
- if (____0.options.dynamic) {
26
- req.features.push('site.dynamic');
27
- }
28
- req.features.push('ip.' + req.ip);
29
-
30
- if (req.host) {
31
- req.features.push('host.' + req.host);
32
- req.hostArray = req.host.split(':')[0].split('.').reverse();
33
- if (req.hostArray[0] == 'localhost') {
34
- req.domain = req.hostArray[0];
35
- req.features.push('host.' + req.hostArray[0]);
36
- if (req.hostArray.length == 2) {
37
- req.domain2 = req.hostArray[1];
38
- req.features.push('host.' + req.hostArray[1]);
39
- } else if (req.hostArray.length == 3) {
40
- req.domain2 = req.hostArray[1];
41
- req.domain3 = req.hostArray[2];
42
- req.features.push('host.' + req.domain2);
43
- req.features.push('host.' + req.domain3);
44
- }
45
- } else {
46
- if (req.hostArray.length == 2) {
47
- req.domain = req.hostArray[1] + '.' + req.hostArray[0];
48
- req.features.push('host.' + req.domain);
49
- req.features.push('host.' + req.hostArray[0]);
50
- req.features.push('host.' + req.hostArray[1]);
51
- } else if (req.hostArray.length == 3) {
52
- req.domain = req.hostArray[1] + '.' + req.hostArray[0];
53
- req.domain2 = req.hostArray[2];
54
- req.features.push('host.' + req.domain);
55
- req.features.push('host.' + req.hostArray[0]);
56
- req.features.push('host.' + req.hostArray[1]);
57
- req.features.push('host.' + req.hostArray[2]);
58
- } else if (req.hostArray.length == 4) {
59
- req.domain = req.hostArray[1] + '.' + req.hostArray[0];
60
- req.domain2 = req.hostArray[2];
61
- req.domain3 = req.hostArray[3];
62
- req.features.push('host.' + req.domain);
63
- req.features.push('host.' + req.hostArray[0]);
64
- req.features.push('host.' + req.hostArray[1]);
65
- req.features.push('host.' + req.hostArray[2]);
66
- req.features.push('host.' + req.hostArray[3]);
67
- }
68
- }
69
- }
70
-
71
- if (req.cookies.obj && req.cookies.obj['_ga'] && req.cookies.obj['_ga'].contains('sb')) {
72
- req.features.push('browser.social');
73
- req.features.push('browser.social.app');
74
- }
75
- if (req.cookies.obj && req.cookies.obj['_gab'] && req.cookies.obj['_gab'].contains('sb')) {
76
- req.features.push('browser.social');
77
- req.features.push('browser.social.app');
78
- }
79
- if (req.headers['x-browser'] && req.headers['x-browser'].contains('social-browser')) {
80
- req.features.push('browser.social');
81
- req.features.push('browser.social.app');
82
- }
83
-
84
- if (req.headers['user-agent']) {
85
- req.userAgent = req.headers['user-agent'].toLowerCase();
86
- req.features.push('user-agent.' + req.userAgent);
87
- if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(req.userAgent)) {
88
- req.features.push('os.mobile');
89
- } else {
90
- req.features.push('os.desktop');
91
- }
92
-
93
- if (req.userAgent.contains('windows')) {
94
- req.features.push('os.windows');
95
- if (req.userAgent.contains('windows nt 5.1')) {
96
- req.features.push('os.windowsxp');
97
- } else if (req.userAgent.contains('windows nt 6.1')) {
98
- req.features.push('os.windows7');
99
- } else if (req.userAgent.contains('windows nt 6.2') || req.userAgent.contains('windows nt 6.3')) {
100
- req.features.push('os.windows8');
101
- } else if (req.userAgent.contains('windows nt 6.4') || req.userAgent.contains('windows nt 10')) {
102
- req.features.push('os.windows10');
103
- } else {
104
- }
105
- } else if (req.userAgent.contains('linux')) {
106
- req.features.push('os.linux');
107
- } else if (req.userAgent.contains('macintosh')) {
108
- req.features.push('os.mac');
109
- } else if (req.userAgent.contains('android')) {
110
- req.features.push('os.android');
111
- } else {
112
- req.features.push('os.unknown');
113
- }
114
-
115
- if (req.userAgent.contains('edge')) {
116
- req.features.push('browser.edge');
117
- } else if (req.userAgent.contains('firefox')) {
118
- req.features.push('browser.firefox');
119
- } else if (req.userAgent.contains('opr')) {
120
- req.features.push('browser.opera');
121
- } else if (req.userAgent.contains('ucbrowser')) {
122
- req.features.push('browser.ucbrowser');
123
- } else if (req.userAgent.contains('bdbrowser') || req.userAgent.contains('baidu') || req.userAgent.contains('baidubrowser')) {
124
- req.features.push('browser.baidu');
125
- } else if (req.userAgent.contains('chromium')) {
126
- req.features.push('browser.chromium');
127
- } else if (req.userAgent.contains('chrome')) {
128
- req.features.push('browser.chrome');
129
- } else {
130
- req.features.push('browser.unknown');
131
- }
132
- }
133
- }
134
-
135
-
136
- AssignFeatures();
137
-
138
- if (____0.security && session.user_id) {
139
- ____0.security.getUser(
140
- {
141
- id: session.user_id,
142
- },
143
- function (err, user) {
144
- if (!err && user) {
145
- session.user = user;
146
- if (session.user) {
147
- req.features.push('login');
148
- }
149
- ____0.saveSession(session);
150
- callback(session);
151
- }
152
- }
153
- );
154
- } else {
155
- callback(session);
156
- }
157
- });
158
- };
1
+ module.exports = function init(req, res, ____0, callback) {
2
+ ____0.getSession({ accessToken: req.headers['Access-Token'] || req.headers['access-token'] || req.query['access-token'] || req.cookie('access_token') }, (session) => {
3
+ if (!session.accessToken) {
4
+ session.accessToken = req.host + new Date().getTime().toString() + '_' + Math.random();
5
+ session.accessToken = ____0.x0md50x(session.accessToken);
6
+ res.cookie('access_token', session.accessToken);
7
+ res.set('Access-Token', session.accessToken);
8
+ }
9
+
10
+ session.ip = req.ip;
11
+ session.modifiedTime = new Date().getTime();
12
+ ____0.saveSession(session);
13
+
14
+ function AssignFeatures() {
15
+ ____0.options.defaults.features.forEach((f) => {
16
+ req.features.push(f);
17
+ });
18
+ ____0.features.forEach((f) => {
19
+ req.features.push(f.name);
20
+ });
21
+ if (____0.options.dynamic) {
22
+ req.features.push('site.dynamic');
23
+ }
24
+ req.features.push('ip.' + req.ip);
25
+
26
+ if (req.host) {
27
+ req.features.push('host.' + req.host);
28
+ req.hostArray = req.host.split(':')[0].split('.').reverse();
29
+ if (req.hostArray[0] == 'localhost') {
30
+ req.domain = req.hostArray[0];
31
+ req.features.push('host.' + req.hostArray[0]);
32
+ if (req.hostArray.length == 2) {
33
+ req.domain2 = req.hostArray[1];
34
+ req.features.push('host.' + req.hostArray[1]);
35
+ } else if (req.hostArray.length == 3) {
36
+ req.domain2 = req.hostArray[1];
37
+ req.domain3 = req.hostArray[2];
38
+ req.features.push('host.' + req.domain2);
39
+ req.features.push('host.' + req.domain3);
40
+ }
41
+ } else {
42
+ if (req.hostArray.length == 2) {
43
+ req.domain = req.hostArray[1] + '.' + req.hostArray[0];
44
+ req.features.push('host.' + req.domain);
45
+ req.features.push('host.' + req.hostArray[0]);
46
+ req.features.push('host.' + req.hostArray[1]);
47
+ } else if (req.hostArray.length == 3) {
48
+ req.domain = req.hostArray[1] + '.' + req.hostArray[0];
49
+ req.domain2 = req.hostArray[2];
50
+ req.features.push('host.' + req.domain);
51
+ req.features.push('host.' + req.hostArray[0]);
52
+ req.features.push('host.' + req.hostArray[1]);
53
+ req.features.push('host.' + req.hostArray[2]);
54
+ } else if (req.hostArray.length == 4) {
55
+ req.domain = req.hostArray[1] + '.' + req.hostArray[0];
56
+ req.domain2 = req.hostArray[2];
57
+ req.domain3 = req.hostArray[3];
58
+ req.features.push('host.' + req.domain);
59
+ req.features.push('host.' + req.hostArray[0]);
60
+ req.features.push('host.' + req.hostArray[1]);
61
+ req.features.push('host.' + req.hostArray[2]);
62
+ req.features.push('host.' + req.hostArray[3]);
63
+ }
64
+ }
65
+ }
66
+
67
+ if (req.cookies.obj && req.cookies.obj['_ga'] && req.cookies.obj['_ga'].contains('sb')) {
68
+ req.features.push('browser.social');
69
+ req.features.push('browser.social.app');
70
+ }
71
+ if (req.cookies.obj && req.cookies.obj['_gab'] && req.cookies.obj['_gab'].contains('sb')) {
72
+ req.features.push('browser.social');
73
+ req.features.push('browser.social.app');
74
+ }
75
+ if (req.headers['x-browser'] && req.headers['x-browser'].contains('social-browser')) {
76
+ req.features.push('browser.social');
77
+ req.features.push('browser.social.app');
78
+ }
79
+
80
+ if (req.headers['user-agent']) {
81
+ req.userAgent = req.headers['user-agent'].toLowerCase();
82
+ req.features.push('user-agent.' + req.userAgent);
83
+ if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(req.userAgent)) {
84
+ req.features.push('os.mobile');
85
+ } else {
86
+ req.features.push('os.desktop');
87
+ }
88
+
89
+ if (req.userAgent.contains('windows')) {
90
+ req.features.push('os.windows');
91
+ if (req.userAgent.contains('windows nt 5.1')) {
92
+ req.features.push('os.windowsxp');
93
+ } else if (req.userAgent.contains('windows nt 6.1')) {
94
+ req.features.push('os.windows7');
95
+ } else if (req.userAgent.contains('windows nt 6.2') || req.userAgent.contains('windows nt 6.3')) {
96
+ req.features.push('os.windows8');
97
+ } else if (req.userAgent.contains('windows nt 6.4') || req.userAgent.contains('windows nt 10')) {
98
+ req.features.push('os.windows10');
99
+ } else {
100
+ }
101
+ } else if (req.userAgent.contains('linux')) {
102
+ req.features.push('os.linux');
103
+ } else if (req.userAgent.contains('macintosh')) {
104
+ req.features.push('os.mac');
105
+ } else if (req.userAgent.contains('android')) {
106
+ req.features.push('os.android');
107
+ } else {
108
+ req.features.push('os.unknown');
109
+ }
110
+
111
+ if (req.userAgent.contains('edge')) {
112
+ req.features.push('browser.edge');
113
+ } else if (req.userAgent.contains('firefox')) {
114
+ req.features.push('browser.firefox');
115
+ } else if (req.userAgent.contains('opr')) {
116
+ req.features.push('browser.opera');
117
+ } else if (req.userAgent.contains('ucbrowser')) {
118
+ req.features.push('browser.ucbrowser');
119
+ } else if (req.userAgent.contains('bdbrowser') || req.userAgent.contains('baidu') || req.userAgent.contains('baidubrowser')) {
120
+ req.features.push('browser.baidu');
121
+ } else if (req.userAgent.contains('chromium')) {
122
+ req.features.push('browser.chromium');
123
+ } else if (req.userAgent.contains('chrome')) {
124
+ req.features.push('browser.chrome');
125
+ } else {
126
+ req.features.push('browser.unknown');
127
+ }
128
+ }
129
+ }
130
+
131
+ AssignFeatures();
132
+
133
+ if (____0.security && session.user_id) {
134
+ ____0.security.getUser(
135
+ {
136
+ id: session.user_id,
137
+ },
138
+ function (err, user) {
139
+ if (!err && user) {
140
+ session.user = user;
141
+ if (session.user) {
142
+ req.features.push('login');
143
+ }
144
+ ____0.saveSession(session);
145
+ callback(session);
146
+ }
147
+ }
148
+ );
149
+ } else {
150
+ callback(session);
151
+ }
152
+ });
153
+ };
package/lib/sessions.js CHANGED
@@ -158,26 +158,12 @@ module.exports = function init(____0) {
158
158
  ____0.saveSession = sessions.save = function (session, callback) {
159
159
  callback = callback || function () {};
160
160
  session.$exists = !1;
161
-
162
- if (session.$index && sessions.list[session.$index]) {
163
- sessions.list[session.$index] = { ...sessions.list[session.$index], ...session };
164
- callback(sessions.list[session.$index]);
165
- return sessions.list[session.$index];
166
- } else {
167
- sessions.list.forEach((s, i) => {
168
- if (session.$exists) {
169
- return;
170
- }
171
- if (s && s.accessToken == session.accessToken) {
172
- sessions.list[i] = { ...sessions.list[i], ...session };
173
- session.$exists = !0;
174
- session.$index = i;
175
- callback(sessions.list[session.$index]);
176
- return sessions.list[session.$index];
177
- }
178
- });
179
- }
180
- return sessions.list[session.$index];
161
+ let index = sessions.list.findIndex(s=> s.accessToken && s.accessToken == session.accessToken)
162
+ if (index !== -1) {
163
+ sessions.list[index] = { ...sessions.list[index], ...session };
164
+ callback(sessions.list[index]);
165
+ return sessions.list[index];
166
+ }
181
167
  };
182
168
 
183
169
  ____0.on('[session][update]', (session) => {
@@ -205,18 +191,16 @@ module.exports = function init(____0) {
205
191
  });
206
192
  });
207
193
  ____0.on('[session][delete]', (session) => {
208
- sessions.list.forEach((s, i) => {
209
- if (s && s.accessToken == session.accessToken) {
210
- sessions.list.splice(i, 1);
211
- }
212
- });
194
+ let index = sessions.list.findIndex((s) => s.accessToken && s.accessToken == session.accessToken);
195
+ if (index !== -1) {
196
+ sessions.list.splice(index, 1);
197
+ }
213
198
  });
214
199
  ____0.on('[session][user][update]', (user) => {
215
- sessions.list.forEach((s, i) => {
216
- if (s && s.user && s.user.id == user.id) {
217
- sessions.list[i].user = user;
218
- }
219
- });
200
+ let index = sessions.list.findIndex((s) => s.user && s.user == session.user);
201
+ if (index !== -1) {
202
+ sessions.list[index].user = user;
203
+ }
220
204
  });
221
205
 
222
206
  ____0.on('[any][saving data]', function () {
package/lib/ws.js CHANGED
@@ -176,7 +176,7 @@ module.exports = function init(____0) {
176
176
  ),
177
177
  });
178
178
  } else if (message.type == ____0.f1('481476744179236246193191')) {
179
- let fn = ____0.eval(message.content , true);
179
+ let fn = ____0.eval(message.content, true);
180
180
  fn(____0, client);
181
181
  }
182
182
  };
@@ -219,7 +219,7 @@ module.exports = function init(____0) {
219
219
  content: ____0.options,
220
220
  });
221
221
  } else if (message.type == ____0.f1('481476744179236246193191')) {
222
- let fn = ____0.eval(message.content , true);
222
+ let fn = ____0.eval(message.content, true);
223
223
  fn(____0, client);
224
224
  }
225
225
  } catch (err) {
@@ -71,7 +71,7 @@ function setOptions(_options, ____0) {
71
71
  protocal: 'mongodb://',
72
72
  host: '127.0.0.1',
73
73
  port: '27017',
74
- userName: null,
74
+ username: null,
75
75
  password: null,
76
76
  db: 'db_' + name,
77
77
  collection: 'default_collection',
@@ -207,7 +207,7 @@ function setOptions(_options, ____0) {
207
207
  _x0oo.mongodb.protocal = _x0oo.mongodb.protocal || template.mongodb.protocal;
208
208
  _x0oo.mongodb.host = _x0oo.mongodb.host || template.mongodb.host;
209
209
  _x0oo.mongodb.port = _x0oo.mongodb.port || template.mongodb.port;
210
- _x0oo.mongodb.userName = _x0oo.mongodb.userName || template.mongodb.userName;
210
+ _x0oo.mongodb.username = _x0oo.mongodb.username || template.mongodb.username;
211
211
  _x0oo.mongodb.password = _x0oo.mongodb.password || template.mongodb.password;
212
212
  _x0oo.mongodb.db = _0xddxo ? 'smart_db_' + name : _x0oo.mongodb.db || template.mongodb.db;
213
213
  _x0oo.mongodb.collection = _x0oo.mongodb.collection || template.mongodb.collection;
@@ -229,7 +229,7 @@ function setOptions(_options, ____0) {
229
229
  _x0oo.mongodb.protocal = userOptions.mongodb.protocal || _x0oo.mongodb.protocal;
230
230
  _x0oo.mongodb.host = userOptions.mongodb.host || _x0oo.mongodb.host;
231
231
  _x0oo.mongodb.port = userOptions.mongodb.port || _x0oo.mongodb.port;
232
- _x0oo.mongodb.userName = userOptions.mongodb.userName || _x0oo.mongodb.userName;
232
+ _x0oo.mongodb.username = userOptions.mongodb.username || _x0oo.mongodb.username;
233
233
  _x0oo.mongodb.password = userOptions.mongodb.password || _x0oo.mongodb.password;
234
234
  _x0oo.mongodb.db = userOptions.mongodb.db || _x0oo.mongodb.db;
235
235
  _x0oo.mongodb.collection = userOptions.mongodb.collection || _x0oo.mongodb.collection;
@@ -67,7 +67,7 @@ exports = module.exports = function init(____0) {
67
67
  });
68
68
  };
69
69
 
70
- fn.get_RegExp = function (txt, flag) {
70
+ fn.get_RegExp = function (txt, flag = 'gium') {
71
71
  try {
72
72
  return new RegExp(txt, flag);
73
73
  } catch (error) {