zmdms-utils 0.0.81 → 0.0.83

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 (162) hide show
  1. package/dist/es/validate.js +168 -1
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -1
  4. package/package.json +2 -6
  5. package/src/index.ts +0 -3
  6. package/src/validate.ts +198 -0
  7. package/dist/es/_virtual/FastBufferList.js +0 -7
  8. package/dist/es/_virtual/_commonjs-dynamic-modules.js +0 -5
  9. package/dist/es/_virtual/browser.js +0 -7
  10. package/dist/es/_virtual/browser2.js +0 -7
  11. package/dist/es/_virtual/debug.js +0 -7
  12. package/dist/es/_virtual/event.js +0 -7
  13. package/dist/es/_virtual/http-parser.js +0 -3
  14. package/dist/es/_virtual/iframe.js +0 -7
  15. package/dist/es/_virtual/index.js +0 -7
  16. package/dist/es/_virtual/index2.js +0 -7
  17. package/dist/es/_virtual/index3.js +0 -7
  18. package/dist/es/_virtual/index4.js +0 -7
  19. package/dist/es/_virtual/index5.js +0 -7
  20. package/dist/es/_virtual/index6.js +0 -7
  21. package/dist/es/_virtual/index7.js +0 -3
  22. package/dist/es/_virtual/index8.js +0 -7
  23. package/dist/es/_virtual/index9.js +0 -7
  24. package/dist/es/_virtual/inherits.js +0 -7
  25. package/dist/es/_virtual/inherits_browser.js +0 -7
  26. package/dist/es/_virtual/json3.js +0 -7
  27. package/dist/es/_virtual/node.js +0 -7
  28. package/dist/es/_virtual/node2.js +0 -7
  29. package/dist/es/_virtual/stomp-node.js +0 -3
  30. package/dist/es/_virtual/stomp.js +0 -3
  31. package/dist/es/_virtual/streams.js +0 -3
  32. package/dist/es/_virtual/utils.js +0 -3
  33. package/dist/es/node_modules/bufferutil/fallback.js +0 -43
  34. package/dist/es/node_modules/bufferutil/index.js +0 -21
  35. package/dist/es/node_modules/debug/src/browser.js +0 -192
  36. package/dist/es/node_modules/debug/src/common.js +0 -259
  37. package/dist/es/node_modules/debug/src/index.js +0 -25
  38. package/dist/es/node_modules/debug/src/node.js +0 -192
  39. package/dist/es/node_modules/eventsource/lib/eventsource.js +0 -493
  40. package/dist/es/node_modules/faye-websocket/lib/faye/eventsource.js +0 -150
  41. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api/event.js +0 -31
  42. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api/event_target.js +0 -41
  43. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api.js +0 -205
  44. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/client.js +0 -107
  45. package/dist/es/node_modules/faye-websocket/lib/faye/websocket.js +0 -47
  46. package/dist/es/node_modules/has-flag/index.js +0 -17
  47. package/dist/es/node_modules/http-parser-js/http-parser.js +0 -471
  48. package/dist/es/node_modules/inherits/inherits.js +0 -14
  49. package/dist/es/node_modules/inherits/inherits_browser.js +0 -38
  50. package/dist/es/node_modules/is-typedarray/index.js +0 -51
  51. package/dist/es/node_modules/json3/lib/json3.js +0 -937
  52. package/dist/es/node_modules/ms/index.js +0 -172
  53. package/dist/es/node_modules/node-gyp-build/index.js +0 -21
  54. package/dist/es/node_modules/node-gyp-build/node-gyp-build.js +0 -222
  55. package/dist/es/node_modules/querystringify/index.js +0 -120
  56. package/dist/es/node_modules/requires-port/index.js +0 -38
  57. package/dist/es/node_modules/safe-buffer/index.js +0 -71
  58. package/dist/es/node_modules/supports-color/index.js +0 -143
  59. package/dist/es/node_modules/typedarray-to-buffer/index.js +0 -37
  60. package/dist/es/node_modules/url-parse/index.js +0 -594
  61. package/dist/es/node_modules/utf-8-validate/fallback.js +0 -71
  62. package/dist/es/node_modules/utf-8-validate/index.js +0 -21
  63. package/dist/es/node_modules/websocket/index.js +0 -15
  64. package/dist/es/node_modules/websocket/lib/Deprecation.js +0 -42
  65. package/dist/es/node_modules/websocket/lib/W3CWebSocket.js +0 -268
  66. package/dist/es/node_modules/websocket/lib/WebSocketClient.js +0 -380
  67. package/dist/es/node_modules/websocket/lib/WebSocketConnection.js +0 -914
  68. package/dist/es/node_modules/websocket/lib/WebSocketFrame.js +0 -293
  69. package/dist/es/node_modules/websocket/lib/WebSocketRequest.js +0 -543
  70. package/dist/es/node_modules/websocket/lib/WebSocketRouter.js +0 -172
  71. package/dist/es/node_modules/websocket/lib/WebSocketRouterRequest.js +0 -67
  72. package/dist/es/node_modules/websocket/lib/WebSocketServer.js +0 -272
  73. package/dist/es/node_modules/websocket/lib/utils.js +0 -80
  74. package/dist/es/node_modules/websocket/lib/version.js +0 -13
  75. package/dist/es/node_modules/websocket/lib/websocket.js +0 -31
  76. package/dist/es/node_modules/websocket/node_modules/debug/src/browser.js +0 -199
  77. package/dist/es/node_modules/websocket/node_modules/debug/src/debug.js +0 -215
  78. package/dist/es/node_modules/websocket/node_modules/debug/src/index.js +0 -25
  79. package/dist/es/node_modules/websocket/node_modules/debug/src/node.js +0 -266
  80. package/dist/es/node_modules/websocket/node_modules/ms/index.js +0 -162
  81. package/dist/es/node_modules/websocket/package.json.js +0 -77
  82. package/dist/es/node_modules/websocket/vendor/FastBufferList.js +0 -205
  83. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/base.js +0 -202
  84. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/client.js +0 -152
  85. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/draft75.js +0 -128
  86. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/draft76.js +0 -124
  87. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/headers.js +0 -44
  88. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi/frame.js +0 -21
  89. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi/message.js +0 -37
  90. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi.js +0 -492
  91. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/proxy.js +0 -108
  92. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/server.js +0 -119
  93. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/stream_reader.js +0 -72
  94. package/dist/es/node_modules/websocket-driver/lib/websocket/driver.js +0 -47
  95. package/dist/es/node_modules/websocket-driver/lib/websocket/http_parser.js +0 -140
  96. package/dist/es/node_modules/websocket-driver/lib/websocket/streams.js +0 -150
  97. package/dist/es/node_modules/websocket-extensions/lib/parser.js +0 -103
  98. package/dist/es/node_modules/websocket-extensions/lib/pipeline/cell.js +0 -56
  99. package/dist/es/node_modules/websocket-extensions/lib/pipeline/functor.js +0 -74
  100. package/dist/es/node_modules/websocket-extensions/lib/pipeline/index.js +0 -50
  101. package/dist/es/node_modules/websocket-extensions/lib/pipeline/pledge.js +0 -39
  102. package/dist/es/node_modules/websocket-extensions/lib/pipeline/ring_buffer.js +0 -66
  103. package/dist/es/node_modules/websocket-extensions/lib/websocket_extensions.js +0 -165
  104. package/dist/es/node_modules/yaeti/index.js +0 -17
  105. package/dist/es/node_modules/yaeti/lib/Event.js +0 -24
  106. package/dist/es/node_modules/yaeti/lib/EventTarget.js +0 -130
  107. package/dist/es/node_modules/zt-sockjs-client/lib/entry.js +0 -14
  108. package/dist/es/node_modules/zt-sockjs-client/lib/event/close.js +0 -21
  109. package/dist/es/node_modules/zt-sockjs-client/lib/event/event.js +0 -22
  110. package/dist/es/node_modules/zt-sockjs-client/lib/event/eventtarget.js +0 -62
  111. package/dist/es/node_modules/zt-sockjs-client/lib/event/trans-message.js +0 -19
  112. package/dist/es/node_modules/zt-sockjs-client/lib/facade.js +0 -40
  113. package/dist/es/node_modules/zt-sockjs-client/lib/iframe-bootstrap.js +0 -122
  114. package/dist/es/node_modules/zt-sockjs-client/lib/info-ajax.js +0 -57
  115. package/dist/es/node_modules/zt-sockjs-client/lib/info-iframe-receiver.js +0 -50
  116. package/dist/es/node_modules/zt-sockjs-client/lib/info-iframe.js +0 -81
  117. package/dist/es/node_modules/zt-sockjs-client/lib/info-receiver.js +0 -101
  118. package/dist/es/node_modules/zt-sockjs-client/lib/location.js +0 -12
  119. package/dist/es/node_modules/zt-sockjs-client/lib/main.js +0 -413
  120. package/dist/es/node_modules/zt-sockjs-client/lib/shims.js +0 -449
  121. package/dist/es/node_modules/zt-sockjs-client/lib/transport/driver/websocket.js +0 -5
  122. package/dist/es/node_modules/zt-sockjs-client/lib/transport/driver/xhr.js +0 -80
  123. package/dist/es/node_modules/zt-sockjs-client/lib/transport/eventsource.js +0 -34
  124. package/dist/es/node_modules/zt-sockjs-client/lib/transport/htmlfile.js +0 -31
  125. package/dist/es/node_modules/zt-sockjs-client/lib/transport/iframe.js +0 -154
  126. package/dist/es/node_modules/zt-sockjs-client/lib/transport/jsonp-polling.js +0 -41
  127. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/ajax-based.js +0 -55
  128. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/buffered-sender.js +0 -92
  129. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/iframe-wrap.js +0 -39
  130. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/polling.js +0 -65
  131. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/sender-receiver.js +0 -52
  132. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/eventsource.js +0 -69
  133. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/htmlfile.js +0 -96
  134. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/jsonp.js +0 -193
  135. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/xhr.js +0 -75
  136. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/jsonp.js +0 -104
  137. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xdr.js +0 -113
  138. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-cors.js +0 -19
  139. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-fake.js +0 -28
  140. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-local.js +0 -21
  141. package/dist/es/node_modules/zt-sockjs-client/lib/transport/websocket.js +0 -108
  142. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xdr-polling.js +0 -30
  143. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xdr-streaming.js +0 -38
  144. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xhr-polling.js +0 -40
  145. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xhr-streaming.js +0 -50
  146. package/dist/es/node_modules/zt-sockjs-client/lib/transport-list.js +0 -28
  147. package/dist/es/node_modules/zt-sockjs-client/lib/utils/browser.js +0 -29
  148. package/dist/es/node_modules/zt-sockjs-client/lib/utils/escape.js +0 -53
  149. package/dist/es/node_modules/zt-sockjs-client/lib/utils/event.js +0 -78
  150. package/dist/es/node_modules/zt-sockjs-client/lib/utils/iframe.js +0 -205
  151. package/dist/es/node_modules/zt-sockjs-client/lib/utils/log.js +0 -20
  152. package/dist/es/node_modules/zt-sockjs-client/lib/utils/object.js +0 -24
  153. package/dist/es/node_modules/zt-sockjs-client/lib/utils/random.js +0 -30
  154. package/dist/es/node_modules/zt-sockjs-client/lib/utils/transport.js +0 -52
  155. package/dist/es/node_modules/zt-sockjs-client/lib/utils/url.js +0 -54
  156. package/dist/es/node_modules/zt-sockjs-client/lib/version.js +0 -11
  157. package/dist/es/node_modules/zt-stompjs/index.js +0 -23
  158. package/dist/es/node_modules/zt-stompjs/lib/stomp-node.js +0 -117
  159. package/dist/es/node_modules/zt-stompjs/lib/stomp.js +0 -536
  160. package/dist/es/stompClient.d.ts +0 -55
  161. package/dist/es/stompClient.js +0 -379
  162. package/src/stompClient.ts +0 -449
@@ -43,5 +43,172 @@ var isChineseValidate = {
43
43
  regex: /[\u4e00-\u9fa5]/,
44
44
  message: "请输入中文!",
45
45
  };
46
+ var alphabet1 = [
47
+ "abcdefghijklmnopqrstuvwxyz",
48
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
49
+ "0123456789",
50
+ ];
51
+ var alphabet2 = ["qwertyuiop", "asdfghjkl", "zxcvbnm"];
52
+ var alphabet3 = ["qaz", "wsx", "edc", "rfv", "tgb", "yhn", "ujm"];
53
+ function isConsecutiveChars(char1, char2, alphabetArr) {
54
+ // const lowerCaseAlphabet = 'abcdefghijklmnopqrstuvwxyz'; // 小写字母
55
+ // const upperCaseAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 大写字母
56
+ // const numeric = '0123456789'; // 数字
57
+ // 找到包含两个字符的字符集
58
+ var alphabet = alphabetArr.find(function (alph) { return alph.includes(char1) && alph.includes(char2); });
59
+ if (!alphabet) {
60
+ return false; // 如果两个字符不在同一字符集中,那么它们不可能连续
61
+ }
62
+ var index1 = alphabet.indexOf(char1);
63
+ var index2 = alphabet.indexOf(char2);
64
+ // return Math.abs(index1 - index2) === 1; // 如果两个字符在字符集中的位置相邻,那么它们是连续的
65
+ return index1 - index2;
66
+ }
67
+ function validatePassword(password, username) {
68
+ // 用正则表达式检查密码基本规则
69
+ var regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$/;
70
+ if (!regex.test(password)) {
71
+ return {
72
+ result: false,
73
+ message: "密码中必须包含大小写字母、数字、特殊字符,且长度必须大于8个字符!",
74
+ };
75
+ }
76
+ // 检查密码是否与用户名相同
77
+ if (password === username) {
78
+ return {
79
+ result: false,
80
+ message: "密码与用户名相同!",
81
+ };
82
+ }
83
+ // 检查密码中是否有相同且连续的字符 超过三次
84
+ var count1 = 0;
85
+ for (var i = 0; i < password.length - 1; i++) {
86
+ if (password[i] === password[i + 1]) {
87
+ count1++;
88
+ if (count1 >= 2) {
89
+ return {
90
+ result: false,
91
+ message: "密码中有相同且连续超过三次的字符!",
92
+ };
93
+ }
94
+ }
95
+ else {
96
+ count1 = 0;
97
+ }
98
+ }
99
+ // 检查密码中是否有连续的字母或数字 连续超过三次
100
+ var count = 0;
101
+ var startChart = 0;
102
+ var currentConsecutiveCount = 0; // 记录上次是递增还是递减
103
+ // 第一次循环 找出 连续字母 数字
104
+ for (var i = 0; i < password.length - 1; i++) {
105
+ var consecutiveCount = isConsecutiveChars(password[i], password[i + 1], alphabet1);
106
+ // 是递增 还是 递减
107
+ if (consecutiveCount === 1 || consecutiveCount === -1) {
108
+ if (currentConsecutiveCount === 0) {
109
+ currentConsecutiveCount = consecutiveCount;
110
+ }
111
+ if (count === 0) {
112
+ startChart = i;
113
+ }
114
+ // 如果记录到上次跟本次的连续规则相同
115
+ if (currentConsecutiveCount === consecutiveCount) {
116
+ count++;
117
+ if (count >= 2) {
118
+ // 密码中不应含有连续的字母或数字
119
+ return {
120
+ result: false,
121
+ message: "\u4ECE\u7B2C".concat(startChart + 1, "\u4E2A\u5B57\u7B26\u5F00\u59CB\uFF0C\u6709\u8FDE\u7EED").concat(currentConsecutiveCount === 1 ? "递减" : "递增", "\u8D85\u8FC7\u4E09\u4F4D\u7684\u5B57\u6BCD\u6216\u6570\u5B57!"),
122
+ };
123
+ }
124
+ }
125
+ else {
126
+ // 需要重置规则
127
+ count = 0;
128
+ startChart = 0;
129
+ }
130
+ currentConsecutiveCount = consecutiveCount;
131
+ }
132
+ else {
133
+ count = 0;
134
+ startChart = 0;
135
+ currentConsecutiveCount = 0;
136
+ }
137
+ }
138
+ // 第二次循环 找出键盘连续横排字母
139
+ for (var i = 0; i < password.length - 1; i++) {
140
+ var consecutiveCount = isConsecutiveChars(password[i], password[i + 1], alphabet2);
141
+ // 是递增 还是 递减
142
+ if (consecutiveCount === 1 || consecutiveCount === -1) {
143
+ if (currentConsecutiveCount === 0) {
144
+ currentConsecutiveCount = consecutiveCount;
145
+ }
146
+ if (count === 0) {
147
+ startChart = i;
148
+ }
149
+ // 如果记录到上次跟本次的连续规则相同
150
+ if (currentConsecutiveCount === consecutiveCount) {
151
+ count++;
152
+ if (count >= 2) {
153
+ // 密码中不应含有连续的字母或数字
154
+ return {
155
+ result: false,
156
+ message: "\u4ECE\u7B2C".concat(startChart + 1, "\u4E2A\u5B57\u7B26\u5F00\u59CB\uFF0C\u6709\u6309\u952E\u76D8\u6A2A\u5411\u8FDE\u7EED").concat(currentConsecutiveCount === 1 ? "递减" : "递增", "\u8D85\u8FC7\u4E09\u4F4D\u7684\u5B57\u6BCD!"),
157
+ };
158
+ }
159
+ }
160
+ else {
161
+ // 需要重置规则
162
+ count = 0;
163
+ startChart = 0;
164
+ }
165
+ currentConsecutiveCount = consecutiveCount;
166
+ }
167
+ else {
168
+ count = 0;
169
+ startChart = 0;
170
+ currentConsecutiveCount = 0;
171
+ }
172
+ }
173
+ // 第三次循环 找出键盘连续竖排字母
174
+ for (var i = 0; i < password.length - 1; i++) {
175
+ var consecutiveCount = isConsecutiveChars(password[i], password[i + 1], alphabet3);
176
+ // 是递增 还是 递减
177
+ if (consecutiveCount === 1 || consecutiveCount === -1) {
178
+ if (currentConsecutiveCount === 0) {
179
+ currentConsecutiveCount = consecutiveCount;
180
+ }
181
+ if (count === 0) {
182
+ startChart = i;
183
+ }
184
+ // 如果记录到上次跟本次的连续规则相同
185
+ if (currentConsecutiveCount === consecutiveCount) {
186
+ count++;
187
+ if (count >= 2) {
188
+ // 密码中不应含有连续的字母或数字
189
+ return {
190
+ result: false,
191
+ message: "\u4ECE\u7B2C".concat(startChart + 1, "\u4E2A\u5B57\u7B26\u5F00\u59CB\uFF0C\u6709\u6309\u952E\u76D8\u7AD6\u5411\u8FDE\u7EED").concat(currentConsecutiveCount === 1 ? "递减" : "递增", "\u8D85\u8FC7\u4E09\u4F4D\u7684\u5B57\u6BCD\u6216\u6570\u5B57!"),
192
+ };
193
+ }
194
+ }
195
+ else {
196
+ // 需要重置规则
197
+ count = 0;
198
+ startChart = 0;
199
+ }
200
+ currentConsecutiveCount = consecutiveCount;
201
+ }
202
+ else {
203
+ count = 0;
204
+ startChart = 0;
205
+ currentConsecutiveCount = 0;
206
+ }
207
+ }
208
+ // 如果通过了所有的检查,则返回true
209
+ return {
210
+ result: true,
211
+ };
212
+ }
46
213
 
47
- export { emailValidate, idCardValidate, isChineseValidate, morePhoneValidate, phoneValidate, strLenValidate };
214
+ export { emailValidate, idCardValidate, isChineseValidate, morePhoneValidate, phoneValidate, strLenValidate, validatePassword };
package/dist/index.d.ts CHANGED
@@ -21,7 +21,6 @@ export { createWater, getDefaultContent, mergeWaterConfig } from './es/water.js'
21
21
  export { initLocale } from './es/locales/i18n.js';
22
22
  export { useTranslation } from './es/locales/use-translation.js';
23
23
  export { safeT } from './es/locales/t-in-non-react.js';
24
- export { default as StompClient } from './es/stompClient.js';
25
24
  export { Base64 } from 'js-base64';
26
25
  export { default as i18n } from 'i18next';
27
26
  export { Trans } from 'react-i18next';
package/dist/index.js CHANGED
@@ -21,7 +21,6 @@ export { createWater, getDefaultContent, mergeWaterConfig } from './es/water.js'
21
21
  export { initLocale } from './es/src/locales/i18n.js';
22
22
  export { useTranslation } from './es/src/locales/use-translation.js';
23
23
  export { safeT } from './es/src/locales/t-in-non-react.js';
24
- export { default as StompClient } from './es/stompClient.js';
25
24
  export { Base64 } from './es/node_modules/js-base64/base64.js';
26
25
  export { default as i18n } from './es/node_modules/i18next/dist/esm/i18next.js';
27
26
  export { Trans } from './es/node_modules/react-i18next/dist/es/Trans.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.81",
3
+ "version": "0.0.83",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -25,11 +25,7 @@
25
25
  "decimal.js": "^10.4.3",
26
26
  "jwt-decode": "3.1.2",
27
27
  "mitt": "^3.0.0",
28
- "pinyin-pro": "^3.18.2",
29
- "sockjs-client": "^1.5.1",
30
- "stompjs": "^2.3.3",
31
- "zt-sockjs-client": "^0.0.2",
32
- "zt-stompjs": "^1.1.2"
28
+ "pinyin-pro": "^3.18.2"
33
29
  },
34
30
  "devDependencies": {
35
31
  "@rollup/plugin-commonjs": "^24.0.1",
package/src/index.ts CHANGED
@@ -82,6 +82,3 @@ export { createWater, mergeWaterConfig, getDefaultContent } from "./water";
82
82
 
83
83
  // 多语言相关
84
84
  export { initLocale, i18n, useTranslation, Trans, safeT } from "./locales";
85
-
86
- // 长连接
87
- export { default as StompClient } from "./stompClient";
package/src/validate.ts CHANGED
@@ -48,3 +48,201 @@ export const isChineseValidate = {
48
48
  regex: /[\u4e00-\u9fa5]/,
49
49
  message: "请输入中文!",
50
50
  };
51
+
52
+ const alphabet1 = [
53
+ "abcdefghijklmnopqrstuvwxyz",
54
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
55
+ "0123456789",
56
+ ];
57
+
58
+ const alphabet2 = ["qwertyuiop", "asdfghjkl", "zxcvbnm"];
59
+ const alphabet3 = ["qaz", "wsx", "edc", "rfv", "tgb", "yhn", "ujm"];
60
+
61
+ function isConsecutiveChars(
62
+ char1: string,
63
+ char2: string,
64
+ alphabetArr: string[]
65
+ ) {
66
+ // const lowerCaseAlphabet = 'abcdefghijklmnopqrstuvwxyz'; // 小写字母
67
+ // const upperCaseAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 大写字母
68
+ // const numeric = '0123456789'; // 数字
69
+
70
+ // 找到包含两个字符的字符集
71
+ const alphabet = alphabetArr.find(
72
+ (alph) => alph.includes(char1) && alph.includes(char2)
73
+ );
74
+
75
+ if (!alphabet) {
76
+ return false; // 如果两个字符不在同一字符集中,那么它们不可能连续
77
+ }
78
+
79
+ const index1 = alphabet.indexOf(char1);
80
+ const index2 = alphabet.indexOf(char2);
81
+
82
+ // return Math.abs(index1 - index2) === 1; // 如果两个字符在字符集中的位置相邻,那么它们是连续的
83
+ return index1 - index2;
84
+ }
85
+
86
+ export function validatePassword(password: string, username: string) {
87
+ // 用正则表达式检查密码基本规则
88
+ const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$/;
89
+ if (!regex.test(password)) {
90
+ return {
91
+ result: false,
92
+ message:
93
+ "密码中必须包含大小写字母、数字、特殊字符,且长度必须大于8个字符!",
94
+ };
95
+ }
96
+
97
+ // 检查密码是否与用户名相同
98
+ if (password === username) {
99
+ return {
100
+ result: false,
101
+ message: "密码与用户名相同!",
102
+ };
103
+ }
104
+
105
+ // 检查密码中是否有相同且连续的字符 超过三次
106
+ let count1 = 0;
107
+ for (let i = 0; i < password.length - 1; i++) {
108
+ if (password[i] === password[i + 1]) {
109
+ count1++;
110
+ if (count1 >= 2) {
111
+ return {
112
+ result: false,
113
+ message: "密码中有相同且连续超过三次的字符!",
114
+ };
115
+ }
116
+ } else {
117
+ count1 = 0;
118
+ }
119
+ }
120
+
121
+ // 检查密码中是否有连续的字母或数字 连续超过三次
122
+ let count = 0;
123
+ let startChart = 0;
124
+ let currentConsecutiveCount = 0; // 记录上次是递增还是递减
125
+
126
+ // 第一次循环 找出 连续字母 数字
127
+ for (let i = 0; i < password.length - 1; i++) {
128
+ const consecutiveCount = isConsecutiveChars(
129
+ password[i],
130
+ password[i + 1],
131
+ alphabet1
132
+ );
133
+ // 是递增 还是 递减
134
+ if (consecutiveCount === 1 || consecutiveCount === -1) {
135
+ if (currentConsecutiveCount === 0) {
136
+ currentConsecutiveCount = consecutiveCount;
137
+ }
138
+ if (count === 0) {
139
+ startChart = i;
140
+ }
141
+ // 如果记录到上次跟本次的连续规则相同
142
+ if (currentConsecutiveCount === consecutiveCount) {
143
+ count++;
144
+ if (count >= 2) {
145
+ // 密码中不应含有连续的字母或数字
146
+ return {
147
+ result: false,
148
+ message: `从第${startChart + 1}个字符开始,有连续${
149
+ currentConsecutiveCount === 1 ? "递减" : "递增"
150
+ }超过三位的字母或数字!`,
151
+ };
152
+ }
153
+ } else {
154
+ // 需要重置规则
155
+ count = 0;
156
+ startChart = 0;
157
+ }
158
+ currentConsecutiveCount = consecutiveCount;
159
+ } else {
160
+ count = 0;
161
+ startChart = 0;
162
+ currentConsecutiveCount = 0;
163
+ }
164
+ }
165
+ // 第二次循环 找出键盘连续横排字母
166
+ for (let i = 0; i < password.length - 1; i++) {
167
+ const consecutiveCount = isConsecutiveChars(
168
+ password[i],
169
+ password[i + 1],
170
+ alphabet2
171
+ );
172
+ // 是递增 还是 递减
173
+ if (consecutiveCount === 1 || consecutiveCount === -1) {
174
+ if (currentConsecutiveCount === 0) {
175
+ currentConsecutiveCount = consecutiveCount;
176
+ }
177
+ if (count === 0) {
178
+ startChart = i;
179
+ }
180
+ // 如果记录到上次跟本次的连续规则相同
181
+ if (currentConsecutiveCount === consecutiveCount) {
182
+ count++;
183
+ if (count >= 2) {
184
+ // 密码中不应含有连续的字母或数字
185
+ return {
186
+ result: false,
187
+ message: `从第${startChart + 1}个字符开始,有按键盘横向连续${
188
+ currentConsecutiveCount === 1 ? "递减" : "递增"
189
+ }超过三位的字母!`,
190
+ };
191
+ }
192
+ } else {
193
+ // 需要重置规则
194
+ count = 0;
195
+ startChart = 0;
196
+ }
197
+ currentConsecutiveCount = consecutiveCount;
198
+ } else {
199
+ count = 0;
200
+ startChart = 0;
201
+ currentConsecutiveCount = 0;
202
+ }
203
+ }
204
+ // 第三次循环 找出键盘连续竖排字母
205
+ for (let i = 0; i < password.length - 1; i++) {
206
+ const consecutiveCount = isConsecutiveChars(
207
+ password[i],
208
+ password[i + 1],
209
+ alphabet3
210
+ );
211
+ // 是递增 还是 递减
212
+ if (consecutiveCount === 1 || consecutiveCount === -1) {
213
+ if (currentConsecutiveCount === 0) {
214
+ currentConsecutiveCount = consecutiveCount;
215
+ }
216
+ if (count === 0) {
217
+ startChart = i;
218
+ }
219
+ // 如果记录到上次跟本次的连续规则相同
220
+ if (currentConsecutiveCount === consecutiveCount) {
221
+ count++;
222
+ if (count >= 2) {
223
+ // 密码中不应含有连续的字母或数字
224
+ return {
225
+ result: false,
226
+ message: `从第${startChart + 1}个字符开始,有按键盘竖向连续${
227
+ currentConsecutiveCount === 1 ? "递减" : "递增"
228
+ }超过三位的字母或数字!`,
229
+ };
230
+ }
231
+ } else {
232
+ // 需要重置规则
233
+ count = 0;
234
+ startChart = 0;
235
+ }
236
+ currentConsecutiveCount = consecutiveCount;
237
+ } else {
238
+ count = 0;
239
+ startChart = 0;
240
+ currentConsecutiveCount = 0;
241
+ }
242
+ }
243
+
244
+ // 如果通过了所有的检查,则返回true
245
+ return {
246
+ result: true,
247
+ };
248
+ }
@@ -1,7 +0,0 @@
1
- var FastBufferListExports = {};
2
- var FastBufferList = {
3
- get exports(){ return FastBufferListExports; },
4
- set exports(v){ FastBufferListExports = v; },
5
- };
6
-
7
- export { FastBufferList as __module, FastBufferListExports as exports };
@@ -1,5 +0,0 @@
1
- function commonjsRequire(path) {
2
- throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
3
- }
4
-
5
- export { commonjsRequire };
@@ -1,7 +0,0 @@
1
- var browserExports = {};
2
- var browser = {
3
- get exports(){ return browserExports; },
4
- set exports(v){ browserExports = v; },
5
- };
6
-
7
- export { browser as __module, browserExports as exports };
@@ -1,7 +0,0 @@
1
- var browserExports = {};
2
- var browser = {
3
- get exports(){ return browserExports; },
4
- set exports(v){ browserExports = v; },
5
- };
6
-
7
- export { browser as __module, browserExports as exports };
@@ -1,7 +0,0 @@
1
- var debugExports = {};
2
- var debug = {
3
- get exports(){ return debugExports; },
4
- set exports(v){ debugExports = v; },
5
- };
6
-
7
- export { debug as __module, debugExports as exports };
@@ -1,7 +0,0 @@
1
- var eventExports = {};
2
- var event = {
3
- get exports(){ return eventExports; },
4
- set exports(v){ eventExports = v; },
5
- };
6
-
7
- export { event as __module, eventExports as exports };
@@ -1,3 +0,0 @@
1
- var httpParser = {};
2
-
3
- export { httpParser as __exports };
@@ -1,7 +0,0 @@
1
- var iframeExports = {};
2
- var iframe = {
3
- get exports(){ return iframeExports; },
4
- set exports(v){ iframeExports = v; },
5
- };
6
-
7
- export { iframe as __module, iframeExports as exports };
@@ -1,7 +0,0 @@
1
- var ztStompjsExports = {};
2
- var ztStompjs = {
3
- get exports(){ return ztStompjsExports; },
4
- set exports(v){ ztStompjsExports = v; },
5
- };
6
-
7
- export { ztStompjs as __module, ztStompjsExports as exports };
@@ -1,7 +0,0 @@
1
- var websocketExports = {};
2
- var websocket = {
3
- get exports(){ return websocketExports; },
4
- set exports(v){ websocketExports = v; },
5
- };
6
-
7
- export { websocket as __module, websocketExports as exports };
@@ -1,7 +0,0 @@
1
- var srcExports = {};
2
- var src = {
3
- get exports(){ return srcExports; },
4
- set exports(v){ srcExports = v; },
5
- };
6
-
7
- export { src as __module, srcExports as exports };
@@ -1,7 +0,0 @@
1
- var bufferutilExports = {};
2
- var bufferutil = {
3
- get exports(){ return bufferutilExports; },
4
- set exports(v){ bufferutilExports = v; },
5
- };
6
-
7
- export { bufferutil as __module, bufferutilExports as exports };
@@ -1,7 +0,0 @@
1
- var utf8ValidateExports = {};
2
- var utf8Validate = {
3
- get exports(){ return utf8ValidateExports; },
4
- set exports(v){ utf8ValidateExports = v; },
5
- };
6
-
7
- export { utf8Validate as __module, utf8ValidateExports as exports };
@@ -1,7 +0,0 @@
1
- var nodeGypBuildExports = {};
2
- var nodeGypBuild = {
3
- get exports(){ return nodeGypBuildExports; },
4
- set exports(v){ nodeGypBuildExports = v; },
5
- };
6
-
7
- export { nodeGypBuild as __module, nodeGypBuildExports as exports };
@@ -1,3 +0,0 @@
1
- var querystringify = {};
2
-
3
- export { querystringify as __exports };
@@ -1,7 +0,0 @@
1
- var srcExports = {};
2
- var src = {
3
- get exports(){ return srcExports; },
4
- set exports(v){ srcExports = v; },
5
- };
6
-
7
- export { src as __module, srcExports as exports };
@@ -1,7 +0,0 @@
1
- var safeBufferExports = {};
2
- var safeBuffer = {
3
- get exports(){ return safeBufferExports; },
4
- set exports(v){ safeBufferExports = v; },
5
- };
6
-
7
- export { safeBuffer as __module, safeBufferExports as exports };
@@ -1,7 +0,0 @@
1
- var inheritsExports = {};
2
- var inherits = {
3
- get exports(){ return inheritsExports; },
4
- set exports(v){ inheritsExports = v; },
5
- };
6
-
7
- export { inherits as __module, inheritsExports as exports };
@@ -1,7 +0,0 @@
1
- var inherits_browserExports = {};
2
- var inherits_browser = {
3
- get exports(){ return inherits_browserExports; },
4
- set exports(v){ inherits_browserExports = v; },
5
- };
6
-
7
- export { inherits_browser as __module, inherits_browserExports as exports };
@@ -1,7 +0,0 @@
1
- var json3Exports = {};
2
- var json3 = {
3
- get exports(){ return json3Exports; },
4
- set exports(v){ json3Exports = v; },
5
- };
6
-
7
- export { json3 as __module, json3Exports as exports };
@@ -1,7 +0,0 @@
1
- var nodeExports = {};
2
- var node = {
3
- get exports(){ return nodeExports; },
4
- set exports(v){ nodeExports = v; },
5
- };
6
-
7
- export { node as __module, nodeExports as exports };
@@ -1,7 +0,0 @@
1
- var nodeExports = {};
2
- var node = {
3
- get exports(){ return nodeExports; },
4
- set exports(v){ nodeExports = v; },
5
- };
6
-
7
- export { node as __module, nodeExports as exports };
@@ -1,3 +0,0 @@
1
- var stompNode = {};
2
-
3
- export { stompNode as __exports };
@@ -1,3 +0,0 @@
1
- var stomp = {};
2
-
3
- export { stomp as __exports };
@@ -1,3 +0,0 @@
1
- var streams = {};
2
-
3
- export { streams as __exports };
@@ -1,3 +0,0 @@
1
- var utils = {};
2
-
3
- export { utils as __exports };
@@ -1,43 +0,0 @@
1
- var fallback;
2
- var hasRequiredFallback;
3
-
4
- function requireFallback () {
5
- if (hasRequiredFallback) return fallback;
6
- hasRequiredFallback = 1;
7
-
8
- /**
9
- * Masks a buffer using the given mask.
10
- *
11
- * @param {Buffer} source The buffer to mask
12
- * @param {Buffer} mask The mask to use
13
- * @param {Buffer} output The buffer where to store the result
14
- * @param {Number} offset The offset at which to start writing
15
- * @param {Number} length The number of bytes to mask.
16
- * @public
17
- */
18
- const mask = (source, mask, output, offset, length) => {
19
- for (var i = 0; i < length; i++) {
20
- output[offset + i] = source[i] ^ mask[i & 3];
21
- }
22
- };
23
-
24
- /**
25
- * Unmasks a buffer using the given mask.
26
- *
27
- * @param {Buffer} buffer The buffer to unmask
28
- * @param {Buffer} mask The mask to use
29
- * @public
30
- */
31
- const unmask = (buffer, mask) => {
32
- // Required until https://github.com/nodejs/node/issues/9006 is resolved.
33
- const length = buffer.length;
34
- for (var i = 0; i < length; i++) {
35
- buffer[i] ^= mask[i & 3];
36
- }
37
- };
38
-
39
- fallback = { mask, unmask };
40
- return fallback;
41
- }
42
-
43
- export { requireFallback as __require };