Skip to content

Commit

Permalink
Merge branch 'master' into feat!/adding-time-base-to-result
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWook committed Feb 6, 2024
2 parents cd6f4ea + a164628 commit b16bd2a
Show file tree
Hide file tree
Showing 22 changed files with 495 additions and 273 deletions.
11 changes: 8 additions & 3 deletions data-scripts/_helpers/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,15 @@ export default class ListHandler {

const hasAdjacencyGraphs = files.includes('adjacencyGraphs.json')

const filesToIgnore = ['translations', 'adjacencyGraphs']
const filesToIgnore = ['translations', 'adjacencyGraphs.json']
const dictionaryExports = files
.map((file) => file.replace('.json', ''))
.filter((file) => !filesToIgnore.includes(file))
.filter((file) => {
return !filesToIgnore.includes(file)
})
.map((file) => {
const dictionaryName = file.replace('.json', '')
return `'${dictionaryName}-${language}': ${dictionaryName}`
})
.join(',\n ')

const translations = isCommon ? '' : 'translations,'
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/framework-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const customMatcher = {
const zxcvbn = new ZxcvbnFactory(options, customMatcher)

const usePasswordStrength = (password: string) => {
const [result, setResult] = (useState < ZxcvbnResult) | (null > null)
const [result, setResult] = useState<ZxcvbnResult | null>(null)
// NOTE: useDeferredValue is React v18 only, for v17 or lower use debouncing
const deferredPassword = useDeferredValue(password)

Expand All @@ -223,7 +223,7 @@ const usePasswordStrength = (password: string) => {
}

export default function PasswordStrength() {
const [password, setPassword] = useState < string > ''
const [password, setPassword] = useState<string>('')
const result = usePasswordStrength(password)
return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/migration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ New:
offlineFastHashingXPerSecond: number
},
crackTimesDisplay: {
onlineThrottlingXPerHour: '1 hour',
onlineThrottlingXPerHour: string,
onlineNoThrottlingXPerSecond: string
offlineSlowHashingXPerSecond: string
offlineFastHashingXPerSecond: string
Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"docs:build": "vuepress build docs"
},
"devDependencies": {
"@babel/cli": "7.23.4",
"@babel/core": "7.23.7",
"@babel/preset-env": "7.23.8",
"@babel/cli": "7.23.9",
"@babel/core": "7.23.9",
"@babel/preset-env": "7.23.9",
"@rollup/plugin-alias": "5.1.0",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-commonjs": "25.0.7",
Expand All @@ -42,18 +42,18 @@
"@rollup/plugin-replace": "5.0.5",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "11.1.6",
"@swc/core": "1.3.104",
"@swc/jest": "0.2.29",
"@swc/core": "1.3.107",
"@swc/jest": "0.2.34",
"@types/byline": "4.2.36",
"@types/jest": "29.5.11",
"@types/sprintf-js": "1.1.4",
"@typescript-eslint/eslint-plugin": "6.19.0",
"@typescript-eslint/parser": "6.19.0",
"@typescript-eslint/eslint-plugin": "6.20.0",
"@typescript-eslint/parser": "6.20.0",
"@vuepress/plugin-register-components": "2.0.0-rc.0",
"axios": "1.6.5",
"axios": "1.6.7",
"byline": "5.0.0",
"cross-fetch": "4.0.0",
"esbuild": "0.19.11",
"esbuild": "0.20.0",
"esbuild-register": "3.5.0",
"eslint": "8.56.0",
"eslint-config-airbnb-base": "15.0.0",
Expand All @@ -78,10 +78,9 @@
"rollup-plugin-copy": "3.5.0",
"rollup-plugin-delete": "2.0.0",
"sprintf-js": "1.1.3",
"ts-jest": "29.1.1",
"ts-jest": "29.1.2",
"typescript": "5.3.3",
"vuepress": "2.0.0-rc.0",
"yarn-audit-fix": "10.0.7",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.1/xlsx-0.20.1.tgz",
"yarn-audit-fix": "10.0.7",
"zxcvbn": "4.4.2"
Expand Down
6 changes: 5 additions & 1 deletion packages/languages/ar/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import lastnames from './lastnames.json'
import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = { firstnames, lastnames, wikipedia }
const dictionary = {
'firstnames-ar': firstnames,
'lastnames-ar': lastnames,
'wikipedia-ar': wikipedia,
}

export { dictionary, translations }
7 changes: 6 additions & 1 deletion packages/languages/cs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import lastnames from './lastnames.json'
import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = { commonWords, firstnames, lastnames, wikipedia }
const dictionary = {
'commonWords-cs': commonWords,
'firstnames-cs': firstnames,
'lastnames-cs': lastnames,
'wikipedia-cs': wikipedia,
}

export { dictionary, translations }
7 changes: 6 additions & 1 deletion packages/languages/de/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import lastnames from './lastnames.json'
import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = { commonWords, firstnames, lastnames, wikipedia }
const dictionary = {
'commonWords-de': commonWords,
'firstnames-de': firstnames,
'lastnames-de': lastnames,
'wikipedia-de': wikipedia,
}

export { dictionary, translations }
7 changes: 6 additions & 1 deletion packages/languages/en/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import lastnames from './lastnames.json'
import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = { commonWords, firstnames, lastnames, wikipedia }
const dictionary = {
'commonWords-en': commonWords,
'firstnames-en': firstnames,
'lastnames-en': lastnames,
'wikipedia-en': wikipedia,
}

export { dictionary, translations }
7 changes: 6 additions & 1 deletion packages/languages/es-es/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import lastnames from './lastnames.json'
import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = { commonWords, firstnames, lastnames, wikipedia }
const dictionary = {
'commonWords-es-es': commonWords,
'firstnames-es-es': firstnames,
'lastnames-es-es': lastnames,
'wikipedia-es-es': wikipedia,
}

export { dictionary, translations }
10 changes: 5 additions & 5 deletions packages/languages/fi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = {
commonWords,
femaleFirstnames,
lastnames,
maleFirstnames,
wikipedia,
'commonWords-fi': commonWords,
'femaleFirstnames-fi': femaleFirstnames,
'lastnames-fi': lastnames,
'maleFirstnames-fi': maleFirstnames,
'wikipedia-fi': wikipedia,
}

export { dictionary, translations }
7 changes: 6 additions & 1 deletion packages/languages/fr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import lastnames from './lastnames.json'
import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = { commonWords, firstnames, lastnames, wikipedia }
const dictionary = {
'commonWords-fr': commonWords,
'firstnames-fr': firstnames,
'lastnames-fr': lastnames,
'wikipedia-fr': wikipedia,
}

export { dictionary, translations }
6 changes: 5 additions & 1 deletion packages/languages/id/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import names from './names.json'
import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = { commonWords, names, wikipedia }
const dictionary = {
'commonWords-id': commonWords,
'names-id': names,
'wikipedia-id': wikipedia,
}

export { dictionary, translations }
7 changes: 6 additions & 1 deletion packages/languages/it/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import lastnames from './lastnames.json'
import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = { commonWords, firstnames, lastnames, wikipedia }
const dictionary = {
'commonWords-it': commonWords,
'firstnames-it': firstnames,
'lastnames-it': lastnames,
'wikipedia-it': wikipedia,
}

export { dictionary, translations }
7 changes: 6 additions & 1 deletion packages/languages/ja/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import lastnames from './lastnames.json'
import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = { commonWords, firstnames, lastnames, wikipedia }
const dictionary = {
'commonWords-ja': commonWords,
'firstnames-ja': firstnames,
'lastnames-ja': lastnames,
'wikipedia-ja': wikipedia,
}

export { dictionary, translations }
10 changes: 5 additions & 5 deletions packages/languages/nl-be/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = {
boysFirstnames,
commonWords,
girlsFirstnames,
lastnames,
wikipedia,
'boysFirstnames-nl-be': boysFirstnames,
'commonWords-nl-be': commonWords,
'girlsFirstnames-nl-be': girlsFirstnames,
'lastnames-nl-be': lastnames,
'wikipedia-nl-be': wikipedia,
}

export { dictionary, translations }
12 changes: 6 additions & 6 deletions packages/languages/pl/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = {
commonWords,
femaleFirstnames,
femaleLastnames,
maleFirstnames,
maleLastnames,
wikipedia,
'commonWords-pl': commonWords,
'femaleFirstnames-pl': femaleFirstnames,
'femaleLastnames-pl': femaleLastnames,
'maleFirstnames-pl': maleFirstnames,
'maleLastnames-pl': maleLastnames,
'wikipedia-pl': wikipedia,
}

export { dictionary, translations }
7 changes: 6 additions & 1 deletion packages/languages/pt-br/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import lastnames from './lastnames.json'
import wikipedia from './wikipedia.json'
import translations from './translations'

const dictionary = { commonWords, firstnames, lastnames, wikipedia }
const dictionary = {
'commonWords-pt-br': commonWords,
'firstnames-pt-br': firstnames,
'lastnames-pt-br': lastnames,
'wikipedia-pt-br': wikipedia,
}

export { dictionary, translations }
27 changes: 16 additions & 11 deletions packages/libraries/main/src/matcher/dictionary/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,25 @@ const getDictionaryWarning = (
match: MatchEstimated,
isSoleMatch?: boolean,
) => {
let warning: string | null = null
const dictName = match.dictionaryName
const isAName =
dictName === 'lastnames' || dictName.toLowerCase().includes('firstnames')
if (dictName === 'passwords') {
warning = getDictionaryWarningPassword(options, match, isSoleMatch)
} else if (dictName.includes('wikipedia')) {
warning = getDictionaryWarningWikipedia(options, match, isSoleMatch)
} else if (isAName) {
warning = getDictionaryWarningNames(options, match, isSoleMatch)
} else if (dictName === 'userInputs') {
warning = options.translations.warnings.userInputs
dictName.toLowerCase().includes('lastnames') ||
dictName.toLowerCase().includes('firstnames')

if (dictName.includes('passwords')) {
return getDictionaryWarningPassword(options, match, isSoleMatch)
}
return warning
if (dictName.includes('wikipedia')) {
return getDictionaryWarningWikipedia(options, match, isSoleMatch)
}
if (isAName) {
return getDictionaryWarningNames(options, match, isSoleMatch)
}
if (dictName.includes('userInputs')) {
return options.translations.warnings.userInputs
}

return null
}

export default (
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/main/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface DictionaryMatch extends Match {
pattern: 'dictionary'
matchedWord: string
rank: number
dictionaryName: DictionaryNames
dictionaryName: DictionaryNames | string
reversed: boolean
l33t: boolean
}
Expand Down
8 changes: 4 additions & 4 deletions packages/libraries/main/test/helper/passwordTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ export default [
token: 'has',
matchedWord: 'has',
rank: 24,
dictionaryName: 'wikipedia',
dictionaryName: 'wikipedia-en',
reversed: false,
l33t: false,
baseGuesses: 24,
Expand All @@ -729,7 +729,7 @@ export default [
token: 'do',
matchedWord: 'do',
rank: 22,
dictionaryName: 'commonWords',
dictionaryName: 'commonWords-en',
reversed: false,
l33t: false,
baseGuesses: 22,
Expand Down Expand Up @@ -929,7 +929,7 @@ export default [
token: 'horse',
matchedWord: 'horse',
rank: 862,
dictionaryName: 'commonWords',
dictionaryName: 'commonWords-en',
reversed: false,
l33t: false,
baseGuesses: 862,
Expand All @@ -953,7 +953,7 @@ export default [
token: 'battery',
matchedWord: 'battery',
rank: 2181,
dictionaryName: 'wikipedia',
dictionaryName: 'wikipedia-en',
reversed: false,
l33t: false,
baseGuesses: 2181,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('dictionary matching', () => {
propsToCheck: {
matchedWord: patterns,
rank: [13],
dictionaryName: ['commonWords'],
dictionaryName: ['commonWords-en'],
},
})
})
Expand Down
Loading

0 comments on commit b16bd2a

Please sign in to comment.