Remove function-style constructor from Keycloak JS (#19912)
This commit is contained in:
parent
4bac7a66ef
commit
5cfa4bedfd
3 changed files with 5 additions and 16 deletions
|
@ -2,6 +2,10 @@
|
|||
|
||||
With this release, we have removed the legacy Promise API methods from the Keycloak JS adapter. This means that calling `.success()` and `.error()` on promises returned from the adapter is no longer possible.
|
||||
|
||||
= Keycloak JS adapter must be instantiated with the `new` operator
|
||||
|
||||
In a previous release we started to actively log deprecation warnings when the Keycloak JS adapter is constructed without the `new` operator. Starting this release doing so will throw an exception instead. This is to align with the expected behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes[JavaScript classes], which will allow further refactoring of the adapter in the future.
|
||||
|
||||
= Export and Import perform an automatic build
|
||||
|
||||
In previous releases, the `export` and `import` commands required a `build` command to be run first.
|
||||
|
|
5
js/libs/keycloak-js/dist/keycloak.d.ts
vendored
5
js/libs/keycloak-js/dist/keycloak.d.ts
vendored
|
@ -332,11 +332,6 @@ export interface KeycloakRoles {
|
|||
*/
|
||||
export type KeycloakInstance = Keycloak;
|
||||
|
||||
/**
|
||||
* @deprecated Construct a Keycloak instance using the `new` keyword instead.
|
||||
*/
|
||||
declare function Keycloak(config?: KeycloakConfig | string): Keycloak;
|
||||
|
||||
/**
|
||||
* A client for the Keycloak authentication server.
|
||||
* @see {@link https://keycloak.gitbooks.io/securing-client-applications-guide/content/topics/oidc/javascript-adapter.html|Keycloak JS adapter documentation}
|
||||
|
|
|
@ -21,19 +21,9 @@ if (typeof Promise === 'undefined') {
|
|||
throw Error('Keycloak requires an environment that supports Promises. Make sure that you include the appropriate polyfill.');
|
||||
}
|
||||
|
||||
var loggedConstructorDeprecation = false;
|
||||
|
||||
function logConstructorDeprecation() {
|
||||
if (!loggedConstructorDeprecation) {
|
||||
loggedConstructorDeprecation = true;
|
||||
console.warn('[KEYCLOAK] Instantiation using the `Keycloak` function has been deprecated and support will be removed in future versions. Use the `new` operator to create an instance instead.');
|
||||
}
|
||||
}
|
||||
|
||||
function Keycloak (config) {
|
||||
if (!(this instanceof Keycloak)) {
|
||||
logConstructorDeprecation();
|
||||
return new Keycloak(config);
|
||||
throw new Error("The 'Keycloak' constructor must be invoked with 'new'.")
|
||||
}
|
||||
|
||||
var kc = this;
|
||||
|
|
Loading…
Reference in a new issue