keycloak-js-adapter-jar.25.0.5.source-code.keycloak-authz.min.js Maven / Gradle / Ivy
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("keycloak-authorization",e):(t="undefined"!=typeof globalThis?globalThis:t||self).KeycloakAuthorization=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var e={exports:{}};!function(e,n){e.exports=function(){function e(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}function n(t){return"function"==typeof t}function r(t){X=t}function o(t){Y=t}function i(){return function(){return process.nextTick(f)}}function s(){return void 0!==J?function(){J(f)}:c()}function u(){var t=0,e=new U(f),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function a(){var t=new MessageChannel;return t.port1.onmessage=f,function(){return t.port2.postMessage(0)}}function c(){var t=setTimeout;return function(){return t(f,1)}}function f(){for(var t=0;t=200&&t<300){var e=JSON.parse(s.responseText).access_token;r.rpt=e,n(e)}else 403==t?o?o():console.error("Authorization request was denied by the server."):i?i():console.error("Could not obtain authorization data from server.")}};var u="grant_type=urn:ietf:params:oauth:grant-type:uma-ticket&client_id="+t.clientId+"&ticket="+e.ticket;null!=e.submitRequest&&(u+="&submit_request="+e.submitRequest);var a=e.metadata;a&&(a.responseIncludeResourceName&&(u+="&response_include_resource_name="+a.responseIncludeResourceName),a.responsePermissionsLimit&&(u+="&response_permissions_limit="+a.responsePermissionsLimit)),r.rpt&&(null==e.incrementalAuthorization||e.incrementalAuthorization)&&(u+="&rpt="+r.rpt),s.send(u)}},this},this.entitlement=function(e,n){return this.then=function(o,i,s){var u=new XMLHttpRequest;u.open("POST",r.config.token_endpoint,!0),u.setRequestHeader("Content-type","application/x-www-form-urlencoded"),u.setRequestHeader("Authorization","Bearer "+t.token),u.onreadystatechange=function(){if(4==u.readyState){var t=u.status;if(t>=200&&t<300){var e=JSON.parse(u.responseText).access_token;r.rpt=e,o(e)}else 403==t?i?i():console.error("Authorization request was denied by the server."):s?s():console.error("Could not obtain authorization data from server.")}},n||(n={});var a="grant_type=urn:ietf:params:oauth:grant-type:uma-ticket&client_id="+t.clientId;n.claimToken&&(a+="&claim_token="+n.claimToken,n.claimTokenFormat&&(a+="&claim_token_format="+n.claimTokenFormat)),a+="&audience="+e;var c=n.permissions;c||(c=[]);for(var f=0;f0){h+="#";for(var p=0;p