@things-factory/auth-base 4.0.32 → 4.0.36
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.
|
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.validatePasswordByRule = exports.passwordHelp = exports.passwordPattern = exports.generatePasswordPatternHelp = void 0;
|
|
7
7
|
const i18next_1 = __importDefault(require("i18next"));
|
|
8
8
|
const env_1 = require("@things-factory/env");
|
|
9
|
-
const utils_1 = require("@things-factory/utils");
|
|
10
|
-
const auth_error_1 = require("../../errors/auth-error");
|
|
11
9
|
const error_code_1 = require("../../constants/error-code");
|
|
10
|
+
const auth_error_1 = require("../../errors/auth-error");
|
|
12
11
|
const debug = require('debug')('things-factory:auth-base:password-rule');
|
|
13
12
|
const passwordConfig = env_1.config.get('password') || {
|
|
14
13
|
lowerCase: true,
|
|
@@ -21,6 +20,31 @@ const passwordConfig = env_1.config.get('password') || {
|
|
|
21
20
|
tightCharacterLength: 8,
|
|
22
21
|
looseCharacterLength: 15
|
|
23
22
|
};
|
|
23
|
+
function generatePasswordPatternRegExp({ lowerCase = true, upperCase = true, digit = true, specialCharacter = true, allowRepeat = false, useTightPattern = true, useLoosePattern = false, tightCharacterLength = 8, looseCharacterLength = 15 } = {}) {
|
|
24
|
+
var tightChecklist = useTightPattern
|
|
25
|
+
? [
|
|
26
|
+
lowerCase ? '(?=.*[a-z])' : '',
|
|
27
|
+
upperCase ? '(?=.*[A-Z])' : '',
|
|
28
|
+
digit ? '(?=.*\\d)' : '',
|
|
29
|
+
specialCharacter ? '(?=.*[!@#$%^&*()])' : '',
|
|
30
|
+
!allowRepeat ? '(?!.*(.)\\1(?=\\1{1,}))' : '',
|
|
31
|
+
`.{${tightCharacterLength},}` // has a length of 8 and more
|
|
32
|
+
]
|
|
33
|
+
: [];
|
|
34
|
+
var looseChecklist = useLoosePattern
|
|
35
|
+
? [
|
|
36
|
+
`.{${looseCharacterLength},}` // has a length of 15 and more
|
|
37
|
+
]
|
|
38
|
+
: [];
|
|
39
|
+
var checkList = [
|
|
40
|
+
'^',
|
|
41
|
+
...tightChecklist,
|
|
42
|
+
tightChecklist.length && looseChecklist.length ? '|' : '',
|
|
43
|
+
...looseChecklist,
|
|
44
|
+
'$' //to the end"
|
|
45
|
+
];
|
|
46
|
+
return new RegExp(checkList.join(''));
|
|
47
|
+
}
|
|
24
48
|
function generatePasswordPatternHelp({ lowerCase = true, upperCase = true, digit = true, specialCharacter = true, allowRepeat = false, useTightPattern = true, useLoosePattern = false, tightCharacterLength = 8, looseCharacterLength = 15 } = {}, lng) {
|
|
25
49
|
lng = lng || 'en-US';
|
|
26
50
|
var descriptions = [];
|
|
@@ -42,7 +66,7 @@ function generatePasswordPatternHelp({ lowerCase = true, upperCase = true, digit
|
|
|
42
66
|
return descriptions.join(', ');
|
|
43
67
|
}
|
|
44
68
|
exports.generatePasswordPatternHelp = generatePasswordPatternHelp;
|
|
45
|
-
exports.passwordPattern =
|
|
69
|
+
exports.passwordPattern = generatePasswordPatternRegExp(passwordConfig);
|
|
46
70
|
function passwordHelp(lng) {
|
|
47
71
|
return generatePasswordPatternHelp(passwordConfig, lng);
|
|
48
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-rule.js","sourceRoot":"","sources":["../../../server/controllers/utils/password-rule.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;
|
|
1
|
+
{"version":3,"file":"password-rule.js","sourceRoot":"","sources":["../../../server/controllers/utils/password-rule.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAE7B,6CAA4C;AAE5C,2DAAyE;AACzE,wDAAmD;AAEnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,wCAAwC,CAAC,CAAA;AACxE,MAAM,cAAc,GAAG,YAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI;IAC/C,SAAS,EAAE,IAAI;IACf,SAAS,EAAE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AA;AAChC,CAAC;AAtCD,kEAsCC;AAEY,QAAA,eAAe,GAAG,6BAA6B,CAAC,cAAc,CAAC,CAAA;AAC5E,SAAgB,YAAY,CAAC,GAAG;IAC9B,OAAO,2BAA2B,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;AACzD,CAAC;AAFD,oCAEC;AAED,SAAgB,sBAAsB,CAAC,QAAQ,EAAE,GAAG;IAClD,IAAI,CAAC,uBAAe,EAAE;QACpB,OAAM;KACP;IAED,IAAI,uBAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAClC,OAAM;KACP;IAED,MAAM,IAAI,GAAG,2BAA2B,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;IAC7D,MAAM,IAAI,sBAAS,CAAC;QAClB,SAAS,EAAE,yCAA4B;QACvC,MAAM,EAAE;YACN,IAAI;SACL;KACF,CAAC,CAAA;AACJ,CAAC;AAhBD,wDAgBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/auth-base",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.36",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -27,10 +27,11 @@
|
|
|
27
27
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@things-factory/email-base": "^4.0.
|
|
31
|
-
"@things-factory/env": "^4.0.
|
|
32
|
-
"@things-factory/i18n-base": "^4.0.
|
|
33
|
-
"@things-factory/shell": "^4.0.
|
|
30
|
+
"@things-factory/email-base": "^4.0.36",
|
|
31
|
+
"@things-factory/env": "^4.0.36",
|
|
32
|
+
"@things-factory/i18n-base": "^4.0.36",
|
|
33
|
+
"@things-factory/shell": "^4.0.36",
|
|
34
|
+
"@things-factory/utils": "^4.0.36",
|
|
34
35
|
"jsonwebtoken": "^8.5.1",
|
|
35
36
|
"koa-passport": "^4.1.4",
|
|
36
37
|
"koa-session": "^6.0.0",
|
|
@@ -40,5 +41,5 @@
|
|
|
40
41
|
"passport-local": "^1.0.0",
|
|
41
42
|
"uuid": "^3.4.0"
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "132ab9f8af8c34f73bcd81a9776769a6929e13ee"
|
|
44
45
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import i18next from 'i18next'
|
|
2
|
+
|
|
2
3
|
import { config } from '@things-factory/env'
|
|
3
|
-
|
|
4
|
-
import { AuthError } from '../../errors/auth-error'
|
|
4
|
+
|
|
5
5
|
import { PASSWORD_PATTERN_NOT_MATCHED } from '../../constants/error-code'
|
|
6
|
+
import { AuthError } from '../../errors/auth-error'
|
|
6
7
|
|
|
7
8
|
const debug = require('debug')('things-factory:auth-base:password-rule')
|
|
8
9
|
const passwordConfig = config.get('password') || {
|
|
@@ -17,6 +18,45 @@ const passwordConfig = config.get('password') || {
|
|
|
17
18
|
looseCharacterLength: 15
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
function generatePasswordPatternRegExp({
|
|
22
|
+
lowerCase = true,
|
|
23
|
+
upperCase = true,
|
|
24
|
+
digit = true,
|
|
25
|
+
specialCharacter = true,
|
|
26
|
+
allowRepeat = false,
|
|
27
|
+
useTightPattern = true,
|
|
28
|
+
useLoosePattern = false,
|
|
29
|
+
tightCharacterLength = 8,
|
|
30
|
+
looseCharacterLength = 15
|
|
31
|
+
} = {}) {
|
|
32
|
+
var tightChecklist = useTightPattern
|
|
33
|
+
? [
|
|
34
|
+
lowerCase ? '(?=.*[a-z])' : '', // has at least one lower case character
|
|
35
|
+
upperCase ? '(?=.*[A-Z])' : '', // has at least one upper case character
|
|
36
|
+
digit ? '(?=.*\\d)' : '', // has at least one digit
|
|
37
|
+
specialCharacter ? '(?=.*[!@#$%^&*()])' : '', // has at least one special character
|
|
38
|
+
!allowRepeat ? '(?!.*(.)\\1(?=\\1{1,}))' : '', // has not an repeated character more than twice
|
|
39
|
+
`.{${tightCharacterLength},}` // has a length of 8 and more
|
|
40
|
+
]
|
|
41
|
+
: []
|
|
42
|
+
|
|
43
|
+
var looseChecklist = useLoosePattern
|
|
44
|
+
? [
|
|
45
|
+
`.{${looseCharacterLength},}` // has a length of 15 and more
|
|
46
|
+
]
|
|
47
|
+
: []
|
|
48
|
+
|
|
49
|
+
var checkList = [
|
|
50
|
+
'^', // from start
|
|
51
|
+
...tightChecklist,
|
|
52
|
+
tightChecklist.length && looseChecklist.length ? '|' : '',
|
|
53
|
+
...looseChecklist,
|
|
54
|
+
'$' //to the end"
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
return new RegExp(checkList.join(''))
|
|
58
|
+
}
|
|
59
|
+
|
|
20
60
|
export function generatePasswordPatternHelp(
|
|
21
61
|
{
|
|
22
62
|
lowerCase = true,
|