Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 46x 46x 46x | /* * Copyright 2021 Harness Inc. All rights reserved. * Use of this source code is governed by the PolyForm Shield 1.0.0 license * that can be found in the licenses directory at the root of this repository, also available at * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt. */ import type { PasswordStrengthPolicy } from 'services/cd-ng' export const DEFAULT_COLOR = '#0063f7' export const MIN_NUMBER_OF_CHARACTERS = 8 export const MAX_NUMBER_OF_CHARACTERS = 64 const getUppercaseRgx = (n: number): string => `^(.*?[A-Z]){${n},}` const getLowercaseRgx = (n: number): string => `^(.*?[a-z]){${n},}` const getNumberRgx = (n: number): string => `^(.*?[0-9]){${n},}` const getSpecialCharRgx = (n: number): string => `^(.*?[ !"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~]){${n},}` export const UPPERCASE_RGX = (n: number): RegExp => new RegExp(getUppercaseRgx(n)) export const LOWERCASE_RGX = (n: number): RegExp => new RegExp(getLowercaseRgx(n)) export const DIGIT_RGX = (n: number): RegExp => new RegExp(getNumberRgx(n)) export const SPECIAL_CHAR_RGX = (n: number): RegExp => new RegExp(getSpecialCharRgx(n)) export const PASSWORD_CHECKS_RGX = ({ enabled, minNumberOfCharacters, minNumberOfUppercaseCharacters, minNumberOfLowercaseCharacters, minNumberOfDigits, minNumberOfSpecialCharacters }: PasswordStrengthPolicy): RegExp => { Iif (!enabled) { return new RegExp(`^.{${MIN_NUMBER_OF_CHARACTERS},${MAX_NUMBER_OF_CHARACTERS}}$`) } const getRegExp = (): string => { let regExp = '' Eif (minNumberOfUppercaseCharacters) { regExp += `(?=.*(${getUppercaseRgx(minNumberOfUppercaseCharacters)}))` } Eif (minNumberOfLowercaseCharacters) { regExp += `(?=.*(${getLowercaseRgx(minNumberOfLowercaseCharacters)}))` } Eif (minNumberOfDigits) { regExp += `(?=.*(${getNumberRgx(minNumberOfDigits)}))` } Eif (minNumberOfSpecialCharacters) { regExp += `(?=.*(${getSpecialCharRgx(minNumberOfSpecialCharacters)}))` } return regExp } return new RegExp( `^${getRegExp()}.{${minNumberOfCharacters || MIN_NUMBER_OF_CHARACTERS},${MAX_NUMBER_OF_CHARACTERS}}$` ) } export enum Experiences { CG = 'CG', NG = 'NG' } |