@springmicro/auth 0.7.0 → 0.7.1

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 (144) hide show
  1. package/.eslintrc.cjs +18 -18
  2. package/README.md +60 -60
  3. package/dist/Index-64ac63ff-ChMmeIY7.js +0 -0
  4. package/dist/Index-6c094240-hn_S7Xeg.js +0 -0
  5. package/dist/Web3Auth-CGD96zai.js +0 -0
  6. package/dist/alphawallet-B7eovdf-.js +0 -0
  7. package/dist/apexwallet-ysP20G9D.js +0 -0
  8. package/dist/atoken-BBnNTzcz.js +0 -0
  9. package/dist/bifrostwallet-CNNBO92h.js +0 -0
  10. package/dist/binance-DvPgAzCw.js +0 -0
  11. package/dist/bitget-DZOUrwgy.js +0 -0
  12. package/dist/bitpie-C_uxmEzw.js +0 -0
  13. package/dist/bitski-DpzkHNkv.js +0 -0
  14. package/dist/blockwallet-BL69cqkA.js +0 -0
  15. package/dist/brave-DnRzMQYW.js +0 -0
  16. package/dist/ccip-c78d2f16-DLcRlwod.js +0 -0
  17. package/dist/coin98wallet-CkFdOvXt.js +0 -0
  18. package/dist/coinbase-CaGNx5if.js +0 -0
  19. package/dist/core-9rK8tWud.js +0 -0
  20. package/dist/defiwallet-0AsgJBSy.js +0 -0
  21. package/dist/detected-CX_JZaUk.js +0 -0
  22. package/dist/echooo-CmaetT_Z.js +0 -0
  23. package/dist/enkrypt-BibtwvK7.js +0 -0
  24. package/dist/exodus-BxzkDWWP.js +0 -0
  25. package/dist/fordefi-CvKyVwhI.js +0 -0
  26. package/dist/foxwallet-D7c_LDTf.js +0 -0
  27. package/dist/frame-CDfNmjUy.js +0 -0
  28. package/dist/frontier-DqKNSj2z.js +0 -0
  29. package/dist/hashMessage-Bdgmx0rg.js +0 -0
  30. package/dist/huobiwallet-CxSwqa5L.js +0 -0
  31. package/dist/hyperpay-nmHE3WqM.js +0 -0
  32. package/dist/icon-2Zqy7pqQ.js +0 -0
  33. package/dist/icon-CGWI1Ies.js +0 -0
  34. package/dist/icon-C_O4nprO.js +0 -0
  35. package/dist/icon-DbgmZCnU.js +0 -0
  36. package/dist/icon-Dbjb6jc5.js +0 -0
  37. package/dist/icon-cAd7RhSC.js +0 -0
  38. package/dist/imtoken-yENtOTS3.js +0 -0
  39. package/dist/index-021f6a62-Zz543EDB.js +0 -0
  40. package/dist/index-40a497ea-Bn2mC0r7.js +0 -0
  41. package/dist/index-62liFLUM.js +0 -0
  42. package/dist/index-BBx_mvyX.js +0 -0
  43. package/dist/index-C6leUA25.js +0 -0
  44. package/dist/index-CAVvArYp.js +0 -0
  45. package/dist/index-Ct7cFdFm.js +0 -0
  46. package/dist/index-DA32_Pfh.js +0 -0
  47. package/dist/index-Dna0rycp.js +0 -0
  48. package/dist/index.d.ts +0 -0
  49. package/dist/index.js +0 -0
  50. package/dist/index.umd.cjs +0 -0
  51. package/dist/infinitywallet-C8J4FUYw.js +0 -0
  52. package/dist/kayros-AIrUK1za.js +0 -0
  53. package/dist/keplr-CyLTca9B.js +0 -0
  54. package/dist/lif3wallet-C5D6r8pg.js +0 -0
  55. package/dist/liquality-nbCtErVq.js +0 -0
  56. package/dist/mathwallet-CWkivCXo.js +0 -0
  57. package/dist/meetone-kKmvI8md.js +0 -0
  58. package/dist/metamask-BN7yiDV1.js +0 -0
  59. package/dist/mykey-CQZ6UcLH.js +0 -0
  60. package/dist/native-FDN9oNjc.js +0 -0
  61. package/dist/number-C-98SESp.js +0 -0
  62. package/dist/okxwallet-CJLVogh2.js +0 -0
  63. package/dist/oneInch-CciyZ4Pz.js +0 -0
  64. package/dist/onekey-Dal8kYjU.js +0 -0
  65. package/dist/opera-DnKg-TJU.js +0 -0
  66. package/dist/ownbit-BshJUVuW.js +0 -0
  67. package/dist/phantom-CJ8dIcov.js +0 -0
  68. package/dist/rabby-D4thTcd6.js +0 -0
  69. package/dist/rainbow-mXld6yWV.js +0 -0
  70. package/dist/roninwallet-ZyYrd-D1.js +0 -0
  71. package/dist/safeheron-Eg1Jb29V.js +0 -0
  72. package/dist/safepal-DVIKy94N.js +0 -0
  73. package/dist/sequence-BS2IbtDg.js +0 -0
  74. package/dist/stablewallet-jyB079Wb.js +0 -0
  75. package/dist/status-FrAvQjfn.js +0 -0
  76. package/dist/subwallet-DMvFqKyY.js +0 -0
  77. package/dist/talisman-Bp8zUXqB.js +0 -0
  78. package/dist/tallywallet-B4OS9nIr.js +0 -0
  79. package/dist/tokenary-C7jjcbQa.js +0 -0
  80. package/dist/tokenpocket-9ZRPmAFA.js +0 -0
  81. package/dist/tp-V2em5bdl.js +0 -0
  82. package/dist/transactionRequest-be6a8ea9-CUKWo5mx.js +0 -0
  83. package/dist/trust-SgHubMq7.js +0 -0
  84. package/dist/xdefi-COVIyGz4.js +0 -0
  85. package/dist/zeal-DxHbDqm0.js +0 -0
  86. package/dist/zerion-BfW0UElc.js +0 -0
  87. package/dist/zodiacpilot-CrId6F4w.js +0 -0
  88. package/index.html +13 -13
  89. package/package.json +2 -2
  90. package/springmicro-auth-0.6.1.tgz +0 -0
  91. package/src/auth/config.ts +0 -0
  92. package/src/components/SignUp.tsx +0 -0
  93. package/src/components/forms/AgreementModal.tsx +88 -88
  94. package/src/components/forms/CaptchaController.tsx +94 -94
  95. package/src/components/forms/CaptchaModal.jsx +171 -171
  96. package/src/components/forms/CaptchaWidget.jsx +146 -146
  97. package/src/components/forms/PasswordChecker.ts +88 -88
  98. package/src/components/forms/SendCodeInput.tsx +0 -0
  99. package/src/components/forms/SignUpFormItem.tsx +0 -0
  100. package/src/components/forms/util/application-api.ts +0 -0
  101. package/src/components/forms/util/auth-api.ts +198 -198
  102. package/src/components/forms/util/auth-util.tsx +346 -346
  103. package/src/components/forms/util/core.ts +493 -493
  104. package/src/components/forms/util/invitation-api.ts +132 -132
  105. package/src/components/forms/util/provider.tsx +603 -603
  106. package/src/components/forms/util/user-api.ts +0 -0
  107. package/src/components/provider/AdfsLoginButton.jsx +38 -38
  108. package/src/components/provider/AlipayLoginButton.jsx +38 -38
  109. package/src/components/provider/AppleLoginButton.jsx +38 -38
  110. package/src/components/provider/AzureADB2CLoginButton.jsx +38 -38
  111. package/src/components/provider/AzureADLoginButton.jsx +38 -38
  112. package/src/components/provider/BaiduLoginButton.jsx +38 -38
  113. package/src/components/provider/BilibiliLoginButton.jsx +37 -37
  114. package/src/components/provider/CasdoorLoginButton.jsx +38 -38
  115. package/src/components/provider/DingTalkLoginButton.jsx +37 -37
  116. package/src/components/provider/DouyinLoginButton.jsx +38 -38
  117. package/src/components/provider/FacebookLoginButton.jsx +37 -37
  118. package/src/components/provider/GitHubLoginButton.jsx +37 -37
  119. package/src/components/provider/GitLabLoginButton.jsx +38 -38
  120. package/src/components/provider/GiteeLoginButton.jsx +34 -34
  121. package/src/components/provider/GoogleLoginButton.jsx +68 -68
  122. package/src/components/provider/InfoflowLoginButton.jsx +38 -38
  123. package/src/components/provider/LarkLoginButton.jsx +38 -38
  124. package/src/components/provider/LinkedInLoginButton.jsx +37 -37
  125. package/src/components/provider/LoginButton.jsx +33 -33
  126. package/src/components/provider/OktaLoginButton.jsx +38 -38
  127. package/src/components/provider/Provider.jsx +3 -3
  128. package/src/components/provider/ProviderButton.jsx +327 -327
  129. package/src/components/provider/QqLoginButton.jsx +31 -31
  130. package/src/components/provider/SelfLoginButton.jsx +47 -47
  131. package/src/components/provider/SlackLoginButton.jsx +38 -38
  132. package/src/components/provider/SteamLoginButton.jsx +38 -38
  133. package/src/components/provider/WeComLoginButton.jsx +34 -34
  134. package/src/components/provider/Web3Auth.jsx +365 -365
  135. package/src/components/provider/WechatLoginButton.jsx +37 -37
  136. package/src/components/provider/WeiboLoginButton.jsx +34 -34
  137. package/src/components/util.tsx +0 -0
  138. package/src/i18n/en/signup.json +48 -48
  139. package/src/i18n/index.ts +17 -17
  140. package/src/index.tsx +0 -0
  141. package/src/vite-env.d.ts +1 -1
  142. package/tsconfig.json +23 -23
  143. package/tsconfig.node.json +10 -10
  144. package/vite.config.ts +33 -33
@@ -1,146 +1,146 @@
1
- // Copyright 2022 The Casdoor Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- import React, { useEffect } from "react";
16
-
17
- export const CaptchaWidget = (props) => {
18
- const {
19
- captchaType,
20
- subType,
21
- siteKey,
22
- clientSecret,
23
- clientId2,
24
- clientSecret2,
25
- onChange,
26
- } = props;
27
-
28
- const loadScript = (src) => {
29
- const tag = document.createElement("script");
30
- tag.async = false;
31
- tag.src = src;
32
- const body = document.getElementsByTagName("body")[0];
33
- body.appendChild(tag);
34
- };
35
-
36
- useEffect(() => {
37
- switch (captchaType) {
38
- case "reCAPTCHA": {
39
- const reTimer = setInterval(() => {
40
- if (!window.grecaptcha) {
41
- loadScript("https://recaptcha.net/recaptcha/api.js");
42
- }
43
- if (window.grecaptcha && window.grecaptcha.render) {
44
- window.grecaptcha.render("captcha", {
45
- sitekey: siteKey,
46
- callback: onChange,
47
- });
48
- clearInterval(reTimer);
49
- }
50
- }, 300);
51
- break;
52
- }
53
- case "hCaptcha": {
54
- const hTimer = setInterval(() => {
55
- if (!window.hcaptcha) {
56
- loadScript("https://js.hcaptcha.com/1/api.js");
57
- }
58
- if (window.hcaptcha && window.hcaptcha.render) {
59
- window.hcaptcha.render("captcha", {
60
- sitekey: siteKey,
61
- callback: onChange,
62
- });
63
- clearInterval(hTimer);
64
- }
65
- }, 300);
66
- break;
67
- }
68
- case "Aliyun Captcha": {
69
- const AWSCTimer = setInterval(() => {
70
- if (!window.AWSC) {
71
- loadScript("https://g.alicdn.com/AWSC/AWSC/awsc.js");
72
- }
73
-
74
- if (window.AWSC) {
75
- if (clientSecret2 && clientSecret2 !== "***") {
76
- window.AWSC.use(subType, function (state, module) {
77
- module.init({
78
- appkey: clientSecret2,
79
- scene: clientId2,
80
- renderTo: "captcha",
81
- success: function (data) {
82
- onChange(
83
- `SessionId=${data.sessionId}&AccessKeyId=${siteKey}&Scene=${clientId2}&AppKey=${clientSecret2}&Token=${data.token}&Sig=${data.sig}&RemoteIp=192.168.0.1`
84
- );
85
- },
86
- });
87
- });
88
- }
89
- clearInterval(AWSCTimer);
90
- }
91
- }, 300);
92
- break;
93
- }
94
- case "GEETEST": {
95
- let getLock = false;
96
- const gTimer = setInterval(() => {
97
- if (!window.initGeetest4) {
98
- loadScript("https://static.geetest.com/v4/gt4.js");
99
- }
100
- if (window.initGeetest4 && siteKey && !getLock) {
101
- const captchaId = String(siteKey);
102
- window.initGeetest4(
103
- {
104
- captchaId,
105
- product: "float",
106
- },
107
- function (captchaObj) {
108
- if (!getLock) {
109
- captchaObj.appendTo("#captcha");
110
- getLock = true;
111
- }
112
- captchaObj.onSuccess(function () {
113
- const result = captchaObj.getValidate();
114
- onChange(
115
- `lot_number=${result.lot_number}&captcha_output=${result.captcha_output}&pass_token=${result.pass_token}&gen_time=${result.gen_time}&captcha_id=${siteKey}`
116
- );
117
- });
118
- }
119
- );
120
- clearInterval(gTimer);
121
- }
122
- }, 500);
123
- break;
124
- }
125
- case "Cloudflare Turnstile": {
126
- const tTimer = setInterval(() => {
127
- if (!window.turnstile) {
128
- loadScript("https://challenges.cloudflare.com/turnstile/v0/api.js");
129
- }
130
- if (window.turnstile && window.turnstile.render) {
131
- window.turnstile.render("#captcha", {
132
- sitekey: siteKey,
133
- callback: onChange,
134
- });
135
- clearInterval(tTimer);
136
- }
137
- }, 300);
138
- break;
139
- }
140
- default:
141
- break;
142
- }
143
- }, [captchaType, subType, siteKey, clientSecret, clientId2, clientSecret2]);
144
-
145
- return <div id="captcha" />;
146
- };
1
+ // Copyright 2022 The Casdoor Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import React, { useEffect } from "react";
16
+
17
+ export const CaptchaWidget = (props) => {
18
+ const {
19
+ captchaType,
20
+ subType,
21
+ siteKey,
22
+ clientSecret,
23
+ clientId2,
24
+ clientSecret2,
25
+ onChange,
26
+ } = props;
27
+
28
+ const loadScript = (src) => {
29
+ const tag = document.createElement("script");
30
+ tag.async = false;
31
+ tag.src = src;
32
+ const body = document.getElementsByTagName("body")[0];
33
+ body.appendChild(tag);
34
+ };
35
+
36
+ useEffect(() => {
37
+ switch (captchaType) {
38
+ case "reCAPTCHA": {
39
+ const reTimer = setInterval(() => {
40
+ if (!window.grecaptcha) {
41
+ loadScript("https://recaptcha.net/recaptcha/api.js");
42
+ }
43
+ if (window.grecaptcha && window.grecaptcha.render) {
44
+ window.grecaptcha.render("captcha", {
45
+ sitekey: siteKey,
46
+ callback: onChange,
47
+ });
48
+ clearInterval(reTimer);
49
+ }
50
+ }, 300);
51
+ break;
52
+ }
53
+ case "hCaptcha": {
54
+ const hTimer = setInterval(() => {
55
+ if (!window.hcaptcha) {
56
+ loadScript("https://js.hcaptcha.com/1/api.js");
57
+ }
58
+ if (window.hcaptcha && window.hcaptcha.render) {
59
+ window.hcaptcha.render("captcha", {
60
+ sitekey: siteKey,
61
+ callback: onChange,
62
+ });
63
+ clearInterval(hTimer);
64
+ }
65
+ }, 300);
66
+ break;
67
+ }
68
+ case "Aliyun Captcha": {
69
+ const AWSCTimer = setInterval(() => {
70
+ if (!window.AWSC) {
71
+ loadScript("https://g.alicdn.com/AWSC/AWSC/awsc.js");
72
+ }
73
+
74
+ if (window.AWSC) {
75
+ if (clientSecret2 && clientSecret2 !== "***") {
76
+ window.AWSC.use(subType, function (state, module) {
77
+ module.init({
78
+ appkey: clientSecret2,
79
+ scene: clientId2,
80
+ renderTo: "captcha",
81
+ success: function (data) {
82
+ onChange(
83
+ `SessionId=${data.sessionId}&AccessKeyId=${siteKey}&Scene=${clientId2}&AppKey=${clientSecret2}&Token=${data.token}&Sig=${data.sig}&RemoteIp=192.168.0.1`
84
+ );
85
+ },
86
+ });
87
+ });
88
+ }
89
+ clearInterval(AWSCTimer);
90
+ }
91
+ }, 300);
92
+ break;
93
+ }
94
+ case "GEETEST": {
95
+ let getLock = false;
96
+ const gTimer = setInterval(() => {
97
+ if (!window.initGeetest4) {
98
+ loadScript("https://static.geetest.com/v4/gt4.js");
99
+ }
100
+ if (window.initGeetest4 && siteKey && !getLock) {
101
+ const captchaId = String(siteKey);
102
+ window.initGeetest4(
103
+ {
104
+ captchaId,
105
+ product: "float",
106
+ },
107
+ function (captchaObj) {
108
+ if (!getLock) {
109
+ captchaObj.appendTo("#captcha");
110
+ getLock = true;
111
+ }
112
+ captchaObj.onSuccess(function () {
113
+ const result = captchaObj.getValidate();
114
+ onChange(
115
+ `lot_number=${result.lot_number}&captcha_output=${result.captcha_output}&pass_token=${result.pass_token}&gen_time=${result.gen_time}&captcha_id=${siteKey}`
116
+ );
117
+ });
118
+ }
119
+ );
120
+ clearInterval(gTimer);
121
+ }
122
+ }, 500);
123
+ break;
124
+ }
125
+ case "Cloudflare Turnstile": {
126
+ const tTimer = setInterval(() => {
127
+ if (!window.turnstile) {
128
+ loadScript("https://challenges.cloudflare.com/turnstile/v0/api.js");
129
+ }
130
+ if (window.turnstile && window.turnstile.render) {
131
+ window.turnstile.render("#captcha", {
132
+ sitekey: siteKey,
133
+ callback: onChange,
134
+ });
135
+ clearInterval(tTimer);
136
+ }
137
+ }, 300);
138
+ break;
139
+ }
140
+ default:
141
+ break;
142
+ }
143
+ }, [captchaType, subType, siteKey, clientSecret, clientId2, clientSecret2]);
144
+
145
+ return <div id="captcha" />;
146
+ };
@@ -1,88 +1,88 @@
1
- // Copyright 2023 The Casdoor Authors. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- import i18next from "i18next";
16
-
17
- function isValidOption_AtLeast6(password: string) {
18
- if (password.length < 6) {
19
- return i18next.t("user:The password must have at least 6 characters");
20
- }
21
- return "";
22
- }
23
-
24
- function isValidOption_AtLeast8(password: string) {
25
- if (password.length < 8) {
26
- return i18next.t("user:The password must have at least 8 characters");
27
- }
28
- return "";
29
- }
30
-
31
- function isValidOption_Aa123(password: string) {
32
- const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).+$/;
33
- if (!regex.test(password)) {
34
- return i18next.t(
35
- "user:The password must contain at least one uppercase letter, one lowercase letter and one digit"
36
- );
37
- }
38
- return "";
39
- }
40
-
41
- function isValidOption_SpecialChar(password: string) {
42
- const regex = /^(?=.*[!-/:-@[-`{-~]).+$/;
43
- if (!regex.test(password)) {
44
- return i18next.t(
45
- "user:The password must contain at least one special character"
46
- );
47
- }
48
- return "";
49
- }
50
-
51
- function isValidOption_NoRepeat(password: string) {
52
- const regex = /(.)\1+/;
53
- if (regex.test(password)) {
54
- return i18next.t(
55
- "user:The password must not contain any repeated characters"
56
- );
57
- }
58
- return "";
59
- }
60
-
61
- export function checkPasswordComplexity(password: string, options: any) {
62
- if (password.length === 0) {
63
- return i18next.t("login:Please input your password!");
64
- }
65
-
66
- if (!options || options.length === 0) {
67
- options = ["AtLeast6"];
68
- }
69
-
70
- const checkers = {
71
- AtLeast6: isValidOption_AtLeast6,
72
- AtLeast8: isValidOption_AtLeast8,
73
- Aa123: isValidOption_Aa123,
74
- SpecialChar: isValidOption_SpecialChar,
75
- NoRepeat: isValidOption_NoRepeat,
76
- };
77
-
78
- for (const option of options) {
79
- const checkerFunc = checkers[option as keyof typeof checkers];
80
- if (checkerFunc) {
81
- const errorMsg = checkerFunc(password);
82
- if (errorMsg !== "") {
83
- return errorMsg;
84
- }
85
- }
86
- }
87
- return "";
88
- }
1
+ // Copyright 2023 The Casdoor Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import i18next from "i18next";
16
+
17
+ function isValidOption_AtLeast6(password: string) {
18
+ if (password.length < 6) {
19
+ return i18next.t("user:The password must have at least 6 characters");
20
+ }
21
+ return "";
22
+ }
23
+
24
+ function isValidOption_AtLeast8(password: string) {
25
+ if (password.length < 8) {
26
+ return i18next.t("user:The password must have at least 8 characters");
27
+ }
28
+ return "";
29
+ }
30
+
31
+ function isValidOption_Aa123(password: string) {
32
+ const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).+$/;
33
+ if (!regex.test(password)) {
34
+ return i18next.t(
35
+ "user:The password must contain at least one uppercase letter, one lowercase letter and one digit"
36
+ );
37
+ }
38
+ return "";
39
+ }
40
+
41
+ function isValidOption_SpecialChar(password: string) {
42
+ const regex = /^(?=.*[!-/:-@[-`{-~]).+$/;
43
+ if (!regex.test(password)) {
44
+ return i18next.t(
45
+ "user:The password must contain at least one special character"
46
+ );
47
+ }
48
+ return "";
49
+ }
50
+
51
+ function isValidOption_NoRepeat(password: string) {
52
+ const regex = /(.)\1+/;
53
+ if (regex.test(password)) {
54
+ return i18next.t(
55
+ "user:The password must not contain any repeated characters"
56
+ );
57
+ }
58
+ return "";
59
+ }
60
+
61
+ export function checkPasswordComplexity(password: string, options: any) {
62
+ if (password.length === 0) {
63
+ return i18next.t("login:Please input your password!");
64
+ }
65
+
66
+ if (!options || options.length === 0) {
67
+ options = ["AtLeast6"];
68
+ }
69
+
70
+ const checkers = {
71
+ AtLeast6: isValidOption_AtLeast6,
72
+ AtLeast8: isValidOption_AtLeast8,
73
+ Aa123: isValidOption_Aa123,
74
+ SpecialChar: isValidOption_SpecialChar,
75
+ NoRepeat: isValidOption_NoRepeat,
76
+ };
77
+
78
+ for (const option of options) {
79
+ const checkerFunc = checkers[option as keyof typeof checkers];
80
+ if (checkerFunc) {
81
+ const errorMsg = checkerFunc(password);
82
+ if (errorMsg !== "") {
83
+ return errorMsg;
84
+ }
85
+ }
86
+ }
87
+ return "";
88
+ }
File without changes
File without changes
File without changes