Skip to content

Commit a880239

Browse files
committed
require stronger password
1 parent aea7230 commit a880239

File tree

9 files changed

+42
-8
lines changed

9 files changed

+42
-8
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Vite Passport
22

3-
## How to run
3+
## How to run for development
44

55
1. `npm install`
66
2. go to [brave://extensions/](brave://extensions/) or [chrome://extensions/](chrome://extensions/)
77
3. turn on dev mode
8-
4. `npm start` which generates `dist` folder
8+
4. `npm run dev` which generates `dist` folder
99
5. drag `dist` folder into extensions tabs or select it in "Load unpacked"
10+
11+
12+
## How to build for production
13+
1. `npm run build` which generates minified `dist` folder

esbuild.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ require('esbuild')
3636
'.json': 'copy',
3737
'.png': 'copy',
3838
},
39+
drop: PROD ? ['console'] : [],
3940
// logLevel: 'debug',
4041
// logLevel: 'silent',
4142
plugins: [

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "Vite Passport",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"icons": {
66
"1024": "src/assets/logo-blue-1024.png"
77
},

package-lock.json

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/containers/TextInput.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type Props = State &
3838
onMetaEnter?: () => void;
3939
placeholder?: string;
4040
optional?: boolean;
41+
showPasswordRequirements?: boolean;
4142
maxLength?: number;
4243
getIssue?: (value: string) => string | void;
4344
onKeyDown?: (key: string) => void;
@@ -67,6 +68,7 @@ const TextInput = ({
6768
textarea,
6869
numeric,
6970
password,
71+
showPasswordRequirements,
7072
initialValue,
7173
resizable,
7274
maxDecimals,
@@ -180,6 +182,15 @@ const TextInput = ({
180182
if (!optional && !trimmedValue) {
181183
errorSet(i18n.thisFieldCannotBeBlank);
182184
return false;
185+
} else if (password) {
186+
if (
187+
internalValue.length < 8 ||
188+
!/[A-Z]/.test(internalValue) ||
189+
!/[0-9]/.test(internalValue)
190+
) {
191+
errorSet(i18n.invalidPassword);
192+
return false;
193+
}
183194
} else if (trimmedValue && getIssue) {
184195
const newIssue = getIssue(trimmedValue) || '';
185196
errorSet(newIssue);
@@ -213,6 +224,11 @@ const TextInput = ({
213224
<div className={`h-0.5 duration-200 ${focused ? 'bg-skin-lowlight' : 'bg-skin-divider'}`} />
214225
)}
215226
{error && <p className="mt-1 text-sm leading-3 font-bold text-red-500">{error}</p>}
227+
{showPasswordRequirements && (
228+
<p className="mt-1 text-xs text-skin-tertiary">
229+
{i18n.mustContainAtLeast8Characters1UppercaseLetterAnd1Number}
230+
</p>
231+
)}
216232
</div>
217233
);
218234
};

src/i18n/en.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ const en = {
174174
none: 'None',
175175
noPrice: 'No Price',
176176
waitForWalletBalanceToLoad: 'Wait for wallet balance to load',
177+
mustContainAtLeast8Characters1UppercaseLetterAnd1Number:
178+
'Must contain at least 8 characters, 1 uppercase letter, and 1 number.',
179+
invalidPassword: 'Invalid password',
177180
test: 'test',
178181
'': '',
179182
};

src/pages/Create2.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ const Create2 = ({ i18n, sendBgScriptPortMessage, setState, secrets }: State) =>
3939
}
4040
}}
4141
/>
42-
<TextInput password containerClassName="mt-4" _ref={passwordRef} label={i18n.password} />
42+
<TextInput
43+
password
44+
showPasswordRequirements
45+
containerClassName="mt-4"
46+
_ref={passwordRef}
47+
label={i18n.password}
48+
/>
4349
<TextInput
4450
password
4551
containerClassName="mt-4"

src/pages/Import.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const Import = ({ i18n, sendBgScriptPortMessage, setState }: State) => {
4040
}
4141
}}
4242
/>
43-
<TextInput password _ref={passwordRef} label={i18n.password} />
43+
<TextInput password showPasswordRequirements _ref={passwordRef} label={i18n.password} />
4444
<TextInput password _ref={confirmPasswordRef} label={i18n.confirmPassword} />
4545
{/* <p className="mt-1 text-skin-tertiary text-sm">{i18n.mustContainAtLeast8Characters}</p> */}
4646
<div className="fx">

src/pages/Settings.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ const Settings = ({
221221
}}
222222
>
223223
<div className="p-3 space-y-3">
224-
<TextInput password _ref={passwordRef} label={i18n.currentPassword} />
224+
<TextInput
225+
password
226+
showPasswordRequirements
227+
_ref={passwordRef}
228+
label={i18n.currentPassword}
229+
/>
225230
<TextInput password _ref={newPasswordRef} label={i18n.newPassword} />
226231
<TextInput password _ref={confirmNewPasswordRef} label={i18n.confirmNewPassword} />
227232
</div>

0 commit comments

Comments
 (0)