Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

keycloak-js

Package Overview
Dependencies
Maintainers
2
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keycloak-js - npm Package Compare versions

Comparing version 4.0.0-beta.3 to 4.0.0

dist/org.keycloak,keycloak-js-adapter,4.0.0.Final,Apache Software License 2.0.txt

2

bower.json
{
"name": "keycloak",
"version": "4.0.0-beta.3",
"version": "4.0.0",
"main": "dist/keycloak.js",

@@ -5,0 +5,0 @@ "ignore": [

@@ -164,2 +164,10 @@ /*

kcLocale?: string;
/**
* Specifies arguments that are passed to the Cordova in-app-browser (if applicable).
* Options 'hidden' and 'location' are not affected by these arguments.
* All available options are defined at https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/.
* Example of use: { zoom: "no", hardwareback: "yes" }
*/
cordovaOptions?: { [optionName: string]: string };
}

@@ -166,0 +174,0 @@

@@ -253,3 +253,12 @@ /*

var scope = (options && options.scope) ? "openid " + options.scope : "openid";
var scope;
if (options && options.scope) {
if (options.scope.indexOf("openid") != -1) {
scope = options.scope;
} else {
scope = "openid " + options.scope;
}
} else {
scope = "openid";
}

@@ -256,0 +265,0 @@ var url = baseUrl

@@ -28,14 +28,14 @@ (function(k,I){var w=function(l){function p(){return"undefined"!==typeof b.authServerUrl?"/"==b.authServerUrl.charAt(b.authServerUrl.length-1)?b.authServerUrl+"realms/"+encodeURIComponent(b.realm):b.authServerUrl+"/realms/"+encodeURIComponent(b.realm):I}function B(a,c){function e(g,d,e,f){x=(x+(new Date).getTime())/2;v(g,d,e,x);C&&(b.tokenParsed&&b.tokenParsed.nonce!=a.storedNonce||b.refreshTokenParsed&&b.refreshTokenParsed.nonce!=a.storedNonce||b.idTokenParsed&&b.idTokenParsed.nonce!=a.storedNonce)?

null,e.newUrl);if(e&&e.valid)return F().success(function(){B(e,d)}).error(function(a){d.setError()});a?a.token&&a.refreshToken?(v(a.token,a.refreshToken,a.idToken),h.enable?F().success(function(){z().success(function(){b.onAuthSuccess&&b.onAuthSuccess();d.setSuccess()}).error(function(){v(null,null,null);d.setSuccess()})}):b.updateToken(-1).success(function(){b.onAuthSuccess&&b.onAuthSuccess();d.setSuccess()}).error(function(){b.onAuthError&&b.onAuthError();a.onLoad?c():d.setError()})):a.onLoad?c():
d.setSuccess():d.setSuccess()});f.error(function(){e.setError()});return e.promise};b.login=function(a){return q.login(a)};b.createLoginUrl=function(a){var c=J(),e=J(),d=q.redirectUri(a),f={state:c,nonce:e,redirectUri:encodeURIComponent(d)};a&&a.prompt&&(f.prompt=a.prompt);y.add(f);var f=a&&"register"==a.action?b.endpoints.register():b.endpoints.authorize(),g=a&&a.scope?"openid "+a.scope:"openid",c=f+"?client_id\x3d"+encodeURIComponent(b.clientId)+"\x26redirect_uri\x3d"+encodeURIComponent(d)+"\x26state\x3d"+
encodeURIComponent(c)+"\x26response_mode\x3d"+encodeURIComponent(b.responseMode)+"\x26response_type\x3d"+encodeURIComponent(b.responseType)+"\x26scope\x3d"+encodeURIComponent(g);C&&(c=c+"\x26nonce\x3d"+encodeURIComponent(e));a&&a.prompt&&(c+="\x26prompt\x3d"+encodeURIComponent(a.prompt));a&&a.maxAge&&(c+="\x26max_age\x3d"+encodeURIComponent(a.maxAge));a&&a.loginHint&&(c+="\x26login_hint\x3d"+encodeURIComponent(a.loginHint));a&&a.idpHint&&(c+="\x26kc_idp_hint\x3d"+encodeURIComponent(a.idpHint));a&&
a.locale&&(c+="\x26ui_locales\x3d"+encodeURIComponent(a.locale));a&&a.kcLocale&&(c+="\x26kc_locale\x3d"+encodeURIComponent(a.kcLocale));return c};b.logout=function(a){return q.logout(a)};b.createLogoutUrl=function(a){return b.endpoints.logout()+"?redirect_uri\x3d"+encodeURIComponent(q.redirectUri(a,!1))};b.register=function(a){return q.register(a)};b.createRegisterUrl=function(a){a||(a={});a.action="register";return b.createLoginUrl(a)};b.createAccountUrl=function(a){var c=p(),e=I;"undefined"!==typeof c&&
(e=c+"/account?referrer\x3d"+encodeURIComponent(b.clientId)+"\x26referrer_uri\x3d"+encodeURIComponent(q.redirectUri(a)));return e};b.accountManagement=function(){return q.accountManagement()};b.hasRealmRole=function(a){var c=b.realmAccess;return!!c&&0<=c.roles.indexOf(a)};b.hasResourceRole=function(a,c){if(!b.resourceAccess)return!1;c=b.resourceAccess[c||b.clientId];return!!c&&0<=c.roles.indexOf(a)};b.loadUserProfile=function(){var a=p()+"/account",c=new XMLHttpRequest;c.open("GET",a,!0);c.setRequestHeader("Accept",
"application/json");c.setRequestHeader("Authorization","bearer "+b.token);var e=m();c.onreadystatechange=function(){4==c.readyState&&(200==c.status?(b.profile=JSON.parse(c.responseText),e.setSuccess(b.profile)):e.setError())};c.send();return e.promise};b.loadUserInfo=function(){var a=b.endpoints.userinfo(),c=new XMLHttpRequest;c.open("GET",a,!0);c.setRequestHeader("Accept","application/json");c.setRequestHeader("Authorization","bearer "+b.token);var e=m();c.onreadystatechange=function(){4==c.readyState&&
(200==c.status?(b.userInfo=JSON.parse(c.responseText),e.setSuccess(b.userInfo)):e.setError())};c.send();return e.promise};b.isTokenExpired=function(a){if(!b.tokenParsed||!b.refreshToken&&"implicit"!=b.flow)throw"Not authenticated";if(null==b.timeSkew)return console.info("[KEYCLOAK] Unable to determine if token is expired as timeskew is not set"),!0;var c=b.tokenParsed.exp-Math.ceil((new Date).getTime()/1E3)+b.timeSkew;a&&(c-=a);return 0>c};b.updateToken=function(a){var c=m();if(!b.refreshToken)return c.setError(),
c.promise;a=a||5;var e=function(){var d=!1;if(-1==a)d=!0,console.info("[KEYCLOAK] Refreshing token: forced refresh");else if(!b.tokenParsed||b.isTokenExpired(a))d=!0,console.info("[KEYCLOAK] Refreshing token: token expired");if(d){var d="grant_type\x3drefresh_token\x26refresh_token\x3d"+b.refreshToken,e=b.endpoints.token();t.push(c);if(1==t.length){var g=new XMLHttpRequest;g.open("POST",e,!0);g.setRequestHeader("Content-type","application/x-www-form-urlencoded");g.withCredentials=!0;b.clientId&&b.clientSecret?
g.setRequestHeader("Authorization","Basic "+btoa(b.clientId+":"+b.clientSecret)):d+="\x26client_id\x3d"+encodeURIComponent(b.clientId);var h=(new Date).getTime();g.onreadystatechange=function(){if(4==g.readyState)if(200==g.status){console.info("[KEYCLOAK] Token refreshed");h=(h+(new Date).getTime())/2;var a=JSON.parse(g.responseText);v(a.access_token,a.refresh_token,a.id_token,h);b.onAuthRefreshSuccess&&b.onAuthRefreshSuccess();for(a=t.pop();null!=a;a=t.pop())a.setSuccess(!0)}else for(console.warn("[KEYCLOAK] Failed to refresh token"),
400==g.status&&b.clearToken(),b.onAuthRefreshError&&b.onAuthRefreshError(),a=t.pop();null!=a;a=t.pop())a.setError(!0)};g.send(d)}}else c.setSuccess(!1)};h.enable?z().success(function(){e()}).error(function(){c.setError()}):e();return c.promise};b.clearToken=function(){b.token&&(v(null,null,null),b.onAuthLogout&&b.onAuthLogout(),b.loginRequired&&b.login())};b.callback_id=0;var G=function(){function a(){for(var a=(new Date).getTime(),b=0;b<localStorage.length;b++){var d=localStorage.key(b);if(d&&0==
d.indexOf("kc-callback-")){var f=localStorage.getItem(d);if(f)try{var g=JSON.parse(f).expires;(!g||g<a)&&localStorage.removeItem(d)}catch(x){localStorage.removeItem(d)}}}}if(!(this instanceof G))return new G;localStorage.setItem("kc-test","test");localStorage.removeItem("kc-test");this.get=function(b){if(b){b="kc-callback-"+b;var c=localStorage.getItem(b);c&&(localStorage.removeItem(b),c=JSON.parse(c));a();return c}};this.add=function(b){a();var c="kc-callback-"+b.state;b.expires=(new Date).getTime()+
36E5;localStorage.setItem(c,JSON.stringify(b))}},H=function(){if(!(this instanceof H))return new H;this.get=function(c){if(c){var d;a:{d="kc-callback-"+c+"\x3d";for(var e=document.cookie.split(";"),g=0;g<e.length;g++){for(var h=e[g];" "==h.charAt(0);)h=h.substring(1);if(0==h.indexOf(d)){d=h.substring(d.length,h.length);break a}}d=""}b("kc-callback-"+c,"",a(-100));if(d)return JSON.parse(d)}};this.add=function(c){b("kc-callback-"+c.state,JSON.stringify(c),a(60))};this.removeItem=function(c){b(c,"",
a(-100))};var a=function(a){var b=new Date;b.setTime(b.getTime()+6E4*a);return b},b=function(a,b,c){a=a+"\x3d"+b+"; expires\x3d"+c.toUTCString()+"; ";document.cookie=a}}};"object"===typeof module&&module&&"object"===typeof module.exports?module.exports=w:(k.Keycloak=w,"function"===typeof define&&define.amd&&define("keycloak",[],function(){return w}))})(window);
d.setSuccess():d.setSuccess()});f.error(function(){e.setError()});return e.promise};b.login=function(a){return q.login(a)};b.createLoginUrl=function(a){var c=J(),e=J(),d=q.redirectUri(a),f={state:c,nonce:e,redirectUri:encodeURIComponent(d)};a&&a.prompt&&(f.prompt=a.prompt);y.add(f);var f=a&&"register"==a.action?b.endpoints.register():b.endpoints.authorize(),g;g=a&&a.scope?-1!=a.scope.indexOf("openid")?a.scope:"openid "+a.scope:"openid";c=f+"?client_id\x3d"+encodeURIComponent(b.clientId)+"\x26redirect_uri\x3d"+
encodeURIComponent(d)+"\x26state\x3d"+encodeURIComponent(c)+"\x26response_mode\x3d"+encodeURIComponent(b.responseMode)+"\x26response_type\x3d"+encodeURIComponent(b.responseType)+"\x26scope\x3d"+encodeURIComponent(g);C&&(c=c+"\x26nonce\x3d"+encodeURIComponent(e));a&&a.prompt&&(c+="\x26prompt\x3d"+encodeURIComponent(a.prompt));a&&a.maxAge&&(c+="\x26max_age\x3d"+encodeURIComponent(a.maxAge));a&&a.loginHint&&(c+="\x26login_hint\x3d"+encodeURIComponent(a.loginHint));a&&a.idpHint&&(c+="\x26kc_idp_hint\x3d"+
encodeURIComponent(a.idpHint));a&&a.locale&&(c+="\x26ui_locales\x3d"+encodeURIComponent(a.locale));a&&a.kcLocale&&(c+="\x26kc_locale\x3d"+encodeURIComponent(a.kcLocale));return c};b.logout=function(a){return q.logout(a)};b.createLogoutUrl=function(a){return b.endpoints.logout()+"?redirect_uri\x3d"+encodeURIComponent(q.redirectUri(a,!1))};b.register=function(a){return q.register(a)};b.createRegisterUrl=function(a){a||(a={});a.action="register";return b.createLoginUrl(a)};b.createAccountUrl=function(a){var c=
p(),e=I;"undefined"!==typeof c&&(e=c+"/account?referrer\x3d"+encodeURIComponent(b.clientId)+"\x26referrer_uri\x3d"+encodeURIComponent(q.redirectUri(a)));return e};b.accountManagement=function(){return q.accountManagement()};b.hasRealmRole=function(a){var c=b.realmAccess;return!!c&&0<=c.roles.indexOf(a)};b.hasResourceRole=function(a,c){if(!b.resourceAccess)return!1;c=b.resourceAccess[c||b.clientId];return!!c&&0<=c.roles.indexOf(a)};b.loadUserProfile=function(){var a=p()+"/account",c=new XMLHttpRequest;
c.open("GET",a,!0);c.setRequestHeader("Accept","application/json");c.setRequestHeader("Authorization","bearer "+b.token);var e=m();c.onreadystatechange=function(){4==c.readyState&&(200==c.status?(b.profile=JSON.parse(c.responseText),e.setSuccess(b.profile)):e.setError())};c.send();return e.promise};b.loadUserInfo=function(){var a=b.endpoints.userinfo(),c=new XMLHttpRequest;c.open("GET",a,!0);c.setRequestHeader("Accept","application/json");c.setRequestHeader("Authorization","bearer "+b.token);var e=
m();c.onreadystatechange=function(){4==c.readyState&&(200==c.status?(b.userInfo=JSON.parse(c.responseText),e.setSuccess(b.userInfo)):e.setError())};c.send();return e.promise};b.isTokenExpired=function(a){if(!b.tokenParsed||!b.refreshToken&&"implicit"!=b.flow)throw"Not authenticated";if(null==b.timeSkew)return console.info("[KEYCLOAK] Unable to determine if token is expired as timeskew is not set"),!0;var c=b.tokenParsed.exp-Math.ceil((new Date).getTime()/1E3)+b.timeSkew;a&&(c-=a);return 0>c};b.updateToken=
function(a){var c=m();if(!b.refreshToken)return c.setError(),c.promise;a=a||5;var e=function(){var d=!1;if(-1==a)d=!0,console.info("[KEYCLOAK] Refreshing token: forced refresh");else if(!b.tokenParsed||b.isTokenExpired(a))d=!0,console.info("[KEYCLOAK] Refreshing token: token expired");if(d){var d="grant_type\x3drefresh_token\x26refresh_token\x3d"+b.refreshToken,e=b.endpoints.token();t.push(c);if(1==t.length){var g=new XMLHttpRequest;g.open("POST",e,!0);g.setRequestHeader("Content-type","application/x-www-form-urlencoded");
g.withCredentials=!0;b.clientId&&b.clientSecret?g.setRequestHeader("Authorization","Basic "+btoa(b.clientId+":"+b.clientSecret)):d+="\x26client_id\x3d"+encodeURIComponent(b.clientId);var h=(new Date).getTime();g.onreadystatechange=function(){if(4==g.readyState)if(200==g.status){console.info("[KEYCLOAK] Token refreshed");h=(h+(new Date).getTime())/2;var a=JSON.parse(g.responseText);v(a.access_token,a.refresh_token,a.id_token,h);b.onAuthRefreshSuccess&&b.onAuthRefreshSuccess();for(a=t.pop();null!=a;a=
t.pop())a.setSuccess(!0)}else for(console.warn("[KEYCLOAK] Failed to refresh token"),400==g.status&&b.clearToken(),b.onAuthRefreshError&&b.onAuthRefreshError(),a=t.pop();null!=a;a=t.pop())a.setError(!0)};g.send(d)}}else c.setSuccess(!1)};h.enable?z().success(function(){e()}).error(function(){c.setError()}):e();return c.promise};b.clearToken=function(){b.token&&(v(null,null,null),b.onAuthLogout&&b.onAuthLogout(),b.loginRequired&&b.login())};b.callback_id=0;var G=function(){function a(){for(var a=(new Date).getTime(),
b=0;b<localStorage.length;b++){var d=localStorage.key(b);if(d&&0==d.indexOf("kc-callback-")){var f=localStorage.getItem(d);if(f)try{var g=JSON.parse(f).expires;(!g||g<a)&&localStorage.removeItem(d)}catch(x){localStorage.removeItem(d)}}}}if(!(this instanceof G))return new G;localStorage.setItem("kc-test","test");localStorage.removeItem("kc-test");this.get=function(b){if(b){b="kc-callback-"+b;var c=localStorage.getItem(b);c&&(localStorage.removeItem(b),c=JSON.parse(c));a();return c}};this.add=function(b){a();
var c="kc-callback-"+b.state;b.expires=(new Date).getTime()+36E5;localStorage.setItem(c,JSON.stringify(b))}},H=function(){if(!(this instanceof H))return new H;this.get=function(c){if(c){var d;a:{d="kc-callback-"+c+"\x3d";for(var e=document.cookie.split(";"),g=0;g<e.length;g++){for(var h=e[g];" "==h.charAt(0);)h=h.substring(1);if(0==h.indexOf(d)){d=h.substring(d.length,h.length);break a}}d=""}b("kc-callback-"+c,"",a(-100));if(d)return JSON.parse(d)}};this.add=function(c){b("kc-callback-"+c.state,JSON.stringify(c),
a(60))};this.removeItem=function(c){b(c,"",a(-100))};var a=function(a){var b=new Date;b.setTime(b.getTime()+6E4*a);return b},b=function(a,b,c){a=a+"\x3d"+b+"; expires\x3d"+c.toUTCString()+"; ";document.cookie=a}}};"object"===typeof module&&module&&"object"===typeof module.exports?module.exports=w:(k.Keycloak=w,"function"===typeof define&&define.amd&&define("keycloak",[],function(){return w}))})(window);
//# sourceMappingURL=keycloak.min.js.map
{
"name": "keycloak-js",
"version": "4.0.0-beta.3",
"version": "4.0.0",
"description": "Keycloak Adapter",

@@ -5,0 +5,0 @@ "main": "dist/keycloak.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc