indatastar-styled-password-strength-meter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +37 -0
- package/lib/module/PasswordStrengthMeter.js +28 -0
- package/lib/module/PasswordStrengthMeter.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/passwordRules.js +18 -0
- package/lib/module/utils/passwordRules.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/PasswordStrengthMeter.d.ts +11 -0
- package/lib/typescript/src/PasswordStrengthMeter.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +20 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/passwordRules.d.ts +4 -0
- package/lib/typescript/src/utils/passwordRules.d.ts.map +1 -0
- package/package.json +160 -0
- package/src/PasswordStrengthMeter.tsx +32 -0
- package/src/index.tsx +3 -0
- package/src/types.ts +21 -0
- package/src/utils/passwordRules.ts +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 InDataStar
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# indatastar-styled-password-strength-meter
|
|
2
|
+
|
|
3
|
+
A lightweight, customizable **password strength meter** for React Native apps.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install indatastar-styled-password-strength-meter
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { multiply } from 'indatastar-styled-password-strength-meter';
|
|
18
|
+
|
|
19
|
+
// ...
|
|
20
|
+
|
|
21
|
+
const result = await multiply(3, 7);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
|
|
27
|
+
- [Development workflow](CONTRIBUTING.md#development-workflow)
|
|
28
|
+
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
|
|
29
|
+
- [Code of conduct](CODE_OF_CONDUCT.md)
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
MIT
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Text, View } from 'react-native';
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export default function PasswordStrengthMeter({
|
|
6
|
+
password,
|
|
7
|
+
containerStyle,
|
|
8
|
+
textStyle
|
|
9
|
+
}) {
|
|
10
|
+
const strength = password.length > 10 ? 'Strong' : password.length > 5 ? 'Medium' : 'Weak';
|
|
11
|
+
const strengthColor = strength === 'Strong' ? 'green' : strength === 'Medium' ? 'orange' : 'red';
|
|
12
|
+
return /*#__PURE__*/_jsx(View, {
|
|
13
|
+
style: containerStyle,
|
|
14
|
+
children: /*#__PURE__*/_jsxs(Text, {
|
|
15
|
+
style: [{
|
|
16
|
+
fontWeight: 'bold'
|
|
17
|
+
}, textStyle],
|
|
18
|
+
children: ["Password Strength:", ' ', /*#__PURE__*/_jsx(Text, {
|
|
19
|
+
style: [{
|
|
20
|
+
color: strengthColor,
|
|
21
|
+
fontWeight: 'bold'
|
|
22
|
+
}, textStyle],
|
|
23
|
+
children: strength
|
|
24
|
+
})]
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=PasswordStrengthMeter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Text","View","jsx","_jsx","jsxs","_jsxs","PasswordStrengthMeter","password","containerStyle","textStyle","strength","length","strengthColor","style","children","fontWeight","color"],"sourceRoot":"../../src","sources":["PasswordStrengthMeter.tsx"],"mappings":";;AAAA,SAASA,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAW1C,eAAe,SAASC,qBAAqBA,CAAC;EAC5CC,QAAQ;EACRC,cAAc;EACdC;AAC0B,CAAC,EAAE;EAC7B,MAAMC,QAAQ,GACZH,QAAQ,CAACI,MAAM,GAAG,EAAE,GAAG,QAAQ,GAAGJ,QAAQ,CAACI,MAAM,GAAG,CAAC,GAAG,QAAQ,GAAG,MAAM;EAC3E,MAAMC,aAAa,GACjBF,QAAQ,KAAK,QAAQ,GAAG,OAAO,GAAGA,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAG,KAAK;EAE5E,oBACEP,IAAA,CAACF,IAAI;IAACY,KAAK,EAAEL,cAAe;IAAAM,QAAA,eAC1BT,KAAA,CAACL,IAAI;MAACa,KAAK,EAAE,CAAC;QAAEE,UAAU,EAAE;MAAO,CAAC,EAAEN,SAAS,CAAE;MAAAK,QAAA,GAAC,oBAC9B,EAAC,GAAG,eACtBX,IAAA,CAACH,IAAI;QAACa,KAAK,EAAE,CAAC;UAAEG,KAAK,EAAEJ,aAAa;UAAEG,UAAU,EAAE;QAAO,CAAC,EAAEN,SAAS,CAAE;QAAAK,QAAA,EACpEJ;MAAQ,CACL,CAAC;IAAA,CACH;EAAC,CACH,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","PasswordStrengthMeter"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AACA,SAAQA,OAAO,IAAIC,qBAAqB,QAAM,4BAAyB;AACvE,cAAc,YAAS","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
//Add in length default is 8 cant be lower
|
|
4
|
+
export function evaluatePasswordStrength(password) {
|
|
5
|
+
if (!password) return 'Weak';
|
|
6
|
+
let score = 0;
|
|
7
|
+
if (password.length >= 8) score += 1;
|
|
8
|
+
if (/[A-Z]/.test(password)) score += 1;
|
|
9
|
+
if (/[0-9]/.test(password)) score += 1;
|
|
10
|
+
if (/[^A-Za-z0-9]/.test(password)) score += 1;
|
|
11
|
+
if (score >= 4) return 'Strong';
|
|
12
|
+
if (score >= 2) return 'Medium';
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
export function isPasswordValid(password) {
|
|
16
|
+
return password.length >= 8 && /[A-Z]/.test(password) && /[0-9]]/.test(password);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=passwordRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["evaluatePasswordStrength","password","score","length","test","undefined","isPasswordValid"],"sourceRoot":"../../../src","sources":["utils/passwordRules.ts"],"mappings":";;AAEA;AACA,OAAO,SAASA,wBAAwBA,CAACC,QAAe,EAAe;EACrE,IAAG,CAACA,QAAQ,EAAE,OAAO,MAAM;EAE3B,IAAIC,KAAK,GAAG,CAAC;EAEb,IAAGD,QAAQ,CAACE,MAAM,IAAE,CAAC,EAAED,KAAK,IAAI,CAAC;EACjC,IAAG,OAAO,CAACE,IAAI,CAACH,QAAQ,CAAC,EAAEC,KAAK,IAAG,CAAC;EACpC,IAAG,OAAO,CAACE,IAAI,CAACH,QAAQ,CAAC,EAAEC,KAAK,IAAG,CAAC;EACpC,IAAG,cAAc,CAACE,IAAI,CAACH,QAAQ,CAAC,EAAEC,KAAK,IAAG,CAAC;EAE3C,IAAGA,KAAK,IAAI,CAAC,EAAE,OAAO,QAAQ;EAC9B,IAAGA,KAAK,IAAI,CAAC,EAAE,OAAO,QAAQ;EAE9B,OAAOG,SAAS;AAClB;AAEA,OAAO,SAASC,eAAeA,CAACL,QAAe,EAAS;EACtD,OAAOA,QAAQ,CAACE,MAAM,IAAI,CAAC,IAAI,OAAO,CAACC,IAAI,CAACH,QAAQ,CAAC,IAAI,QAAQ,CAACG,IAAI,CAACH,QAAQ,CAAC;AAClF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
import type { StyleProp } from 'react-native';
|
|
3
|
+
import type { TextStyle } from 'react-native';
|
|
4
|
+
type PasswordStrengthMeterProps = {
|
|
5
|
+
password: string;
|
|
6
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
7
|
+
textStyle?: StyleProp<TextStyle>;
|
|
8
|
+
};
|
|
9
|
+
export default function PasswordStrengthMeter({ password, containerStyle, textStyle, }: PasswordStrengthMeterProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=PasswordStrengthMeter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordStrengthMeter.d.ts","sourceRoot":"","sources":["../../../src/PasswordStrengthMeter.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAG,SAAS,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAG,SAAS,EAAC,MAAM,cAAc,CAAC;AAE9C,KAAK,0BAA0B,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,QAAQ,EACR,cAAc,EACd,SAAS,GACV,EAAE,0BAA0B,2CAgB5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,IAAI,qBAAqB,EAAC,MAAK,yBAAyB,CAAA;AACvE,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StyleProp } from 'react-native';
|
|
2
|
+
import type { TextStyle } from 'react-native';
|
|
3
|
+
import type { ViewStyle } from 'react-native';
|
|
4
|
+
import type { StrengthLevel } from './utils/passwordRules';
|
|
5
|
+
export type PasswordStrengthMeterProps = {
|
|
6
|
+
password: string;
|
|
7
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
8
|
+
textStyle?: StyleProp<TextStyle>;
|
|
9
|
+
onChangeStrength?: () => void;
|
|
10
|
+
};
|
|
11
|
+
export type PasswordStrengthBarProps = {
|
|
12
|
+
strength: StrengthLevel;
|
|
13
|
+
colors?: {
|
|
14
|
+
Weak?: string;
|
|
15
|
+
Medium?: string;
|
|
16
|
+
Strong?: string;
|
|
17
|
+
};
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAEzD,MAAM,MAAM,0BAA0B,GAAC;IACrC,QAAQ,EAAC,MAAM,CAAC;IAChB,cAAc,CAAC,EAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,SAAS,CAAC,EAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,gBAAgB,CAAC,EAAC,MAAI,IAAI,CAAC;CAC5B,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAC;IACnC,QAAQ,EAAC,aAAa,CAAC;IACvB,MAAM,CAAC,EAAC;QACN,IAAI,CAAC,EAAC,MAAM,CAAC;QACb,MAAM,CAAC,EAAC,MAAM,CAAC;QACf,MAAM,CAAC,EAAC,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAC,SAAS,CAAC,SAAS,CAAC,CAAC;CAC7B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passwordRules.d.ts","sourceRoot":"","sources":["../../../../src/utils/passwordRules.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAE,MAAM,GAAC,QAAQ,GAAC,QAAQ,GAAC,SAAS,CAAA;AAE7D,wBAAgB,wBAAwB,CAAC,QAAQ,EAAC,MAAM,GAAE,aAAa,CActE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAC,MAAM,GAAE,OAAO,CAEvD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "indatastar-styled-password-strength-meter",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A lightweight, customizable **password strength meter** for React Native apps. ",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"example": "yarn workspace indatastar-styled-password-strength-meter-example",
|
|
36
|
+
"clean": "del-cli lib",
|
|
37
|
+
"prepare": "bob build",
|
|
38
|
+
"typecheck": "tsc",
|
|
39
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
40
|
+
"test": "jest",
|
|
41
|
+
"release": "release-it --only-version"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"react-native",
|
|
45
|
+
"ios",
|
|
46
|
+
"android"
|
|
47
|
+
],
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/InDataStar/indatastar-styled-password-strength-meter.git"
|
|
51
|
+
},
|
|
52
|
+
"author": "InDataStar <crawfordlp1@gmail.com> (https://github.com/InDataStar)",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/InDataStar/indatastar-styled-password-strength-meter/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/InDataStar/indatastar-styled-password-strength-meter#readme",
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
63
|
+
"@eslint/compat": "^1.3.2",
|
|
64
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
65
|
+
"@eslint/js": "^9.35.0",
|
|
66
|
+
"@react-native/babel-preset": "0.83.0",
|
|
67
|
+
"@react-native/eslint-config": "0.83.0",
|
|
68
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
69
|
+
"@types/jest": "^29.5.14",
|
|
70
|
+
"@types/react": "^19.1.12",
|
|
71
|
+
"commitlint": "^19.8.1",
|
|
72
|
+
"del-cli": "^6.0.0",
|
|
73
|
+
"eslint": "^9.35.0",
|
|
74
|
+
"eslint-config-prettier": "^10.1.8",
|
|
75
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
76
|
+
"jest": "^29.7.0",
|
|
77
|
+
"lefthook": "^2.0.3",
|
|
78
|
+
"prettier": "^3.8.1",
|
|
79
|
+
"react": "19.1.0",
|
|
80
|
+
"react-native": "0.81.5",
|
|
81
|
+
"react-native-builder-bob": "^0.40.13",
|
|
82
|
+
"release-it": "^19.0.4",
|
|
83
|
+
"typescript": "^5.9.2"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"react": "*",
|
|
87
|
+
"react-native": "*"
|
|
88
|
+
},
|
|
89
|
+
"workspaces": [
|
|
90
|
+
"example"
|
|
91
|
+
],
|
|
92
|
+
"packageManager": "yarn@4.11.0",
|
|
93
|
+
"react-native-builder-bob": {
|
|
94
|
+
"source": "src",
|
|
95
|
+
"output": "lib",
|
|
96
|
+
"targets": [
|
|
97
|
+
[
|
|
98
|
+
"module",
|
|
99
|
+
{
|
|
100
|
+
"esm": true
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
"typescript",
|
|
105
|
+
{
|
|
106
|
+
"project": "tsconfig.build.json"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"prettier": {
|
|
112
|
+
"quoteProps": "consistent",
|
|
113
|
+
"singleQuote": true,
|
|
114
|
+
"tabWidth": 2,
|
|
115
|
+
"trailingComma": "es5",
|
|
116
|
+
"useTabs": false
|
|
117
|
+
},
|
|
118
|
+
"jest": {
|
|
119
|
+
"preset": "react-native",
|
|
120
|
+
"modulePathIgnorePatterns": [
|
|
121
|
+
"<rootDir>/example/node_modules",
|
|
122
|
+
"<rootDir>/lib/"
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
"commitlint": {
|
|
126
|
+
"extends": [
|
|
127
|
+
"@commitlint/config-conventional"
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"release-it": {
|
|
131
|
+
"git": {
|
|
132
|
+
"commitMessage": "chore: release ${version}",
|
|
133
|
+
"tagName": "v${version}"
|
|
134
|
+
},
|
|
135
|
+
"npm": {
|
|
136
|
+
"publish": true
|
|
137
|
+
},
|
|
138
|
+
"github": {
|
|
139
|
+
"release": true
|
|
140
|
+
},
|
|
141
|
+
"plugins": {
|
|
142
|
+
"@release-it/conventional-changelog": {
|
|
143
|
+
"preset": {
|
|
144
|
+
"name": "angular"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"create-react-native-library": {
|
|
150
|
+
"type": "library",
|
|
151
|
+
"languages": "js",
|
|
152
|
+
"tools": [
|
|
153
|
+
"eslint",
|
|
154
|
+
"jest",
|
|
155
|
+
"lefthook",
|
|
156
|
+
"release-it"
|
|
157
|
+
],
|
|
158
|
+
"version": "0.57.0"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Text, View } from 'react-native';
|
|
2
|
+
import type { ViewStyle} from 'react-native';
|
|
3
|
+
import type { StyleProp} from 'react-native';
|
|
4
|
+
import type { TextStyle} from 'react-native';
|
|
5
|
+
|
|
6
|
+
type PasswordStrengthMeterProps = {
|
|
7
|
+
password: string;
|
|
8
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
9
|
+
textStyle?: StyleProp<TextStyle>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default function PasswordStrengthMeter({
|
|
13
|
+
password,
|
|
14
|
+
containerStyle,
|
|
15
|
+
textStyle,
|
|
16
|
+
}: PasswordStrengthMeterProps) {
|
|
17
|
+
const strength =
|
|
18
|
+
password.length > 10 ? 'Strong' : password.length > 5 ? 'Medium' : 'Weak';
|
|
19
|
+
const strengthColor =
|
|
20
|
+
strength === 'Strong' ? 'green' : strength === 'Medium' ? 'orange' : 'red';
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<View style={containerStyle}>
|
|
24
|
+
<Text style={[{ fontWeight: 'bold' }, textStyle]}>
|
|
25
|
+
Password Strength:{' '}
|
|
26
|
+
<Text style={[{ color: strengthColor, fontWeight: 'bold' }, textStyle]}>
|
|
27
|
+
{strength}
|
|
28
|
+
</Text>
|
|
29
|
+
</Text>
|
|
30
|
+
</View>
|
|
31
|
+
);
|
|
32
|
+
}
|
package/src/index.tsx
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {StyleProp} from 'react-native';
|
|
2
|
+
import type {TextStyle} from 'react-native';
|
|
3
|
+
import type {ViewStyle} from 'react-native';
|
|
4
|
+
import type {StrengthLevel} from './utils/passwordRules';
|
|
5
|
+
|
|
6
|
+
export type PasswordStrengthMeterProps={
|
|
7
|
+
password:string;
|
|
8
|
+
containerStyle?:StyleProp<ViewStyle>;
|
|
9
|
+
textStyle?:StyleProp<TextStyle>;
|
|
10
|
+
onChangeStrength?:()=>void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type PasswordStrengthBarProps={
|
|
14
|
+
strength:StrengthLevel;
|
|
15
|
+
colors?:{
|
|
16
|
+
Weak?:string;
|
|
17
|
+
Medium?:string;
|
|
18
|
+
Strong?:string;
|
|
19
|
+
};
|
|
20
|
+
style?:StyleProp<ViewStyle>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
export type StrengthLevel ='Weak'|'Medium'|'Strong'|undefined
|
|
3
|
+
//Add in length default is 8 cant be lower
|
|
4
|
+
export function evaluatePasswordStrength(password:string):StrengthLevel{
|
|
5
|
+
if(!password) return 'Weak';
|
|
6
|
+
|
|
7
|
+
let score = 0;
|
|
8
|
+
|
|
9
|
+
if(password.length>=8) score += 1;
|
|
10
|
+
if(/[A-Z]/.test(password)) score +=1;
|
|
11
|
+
if(/[0-9]/.test(password)) score +=1;
|
|
12
|
+
if(/[^A-Za-z0-9]/.test(password)) score +=1;
|
|
13
|
+
|
|
14
|
+
if(score >= 4) return 'Strong';
|
|
15
|
+
if(score >= 2) return 'Medium';
|
|
16
|
+
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function isPasswordValid(password:string):boolean{
|
|
21
|
+
return password.length >= 8 && /[A-Z]/.test(password) && /[0-9]]/.test(password);
|
|
22
|
+
}
|