diff --git a/docs/documentation/release_notes/topics/22_0_0.adoc b/docs/documentation/release_notes/topics/22_0_0.adoc index 8523883742..1a50f6b200 100644 --- a/docs/documentation/release_notes/topics/22_0_0.adoc +++ b/docs/documentation/release_notes/topics/22_0_0.adoc @@ -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. diff --git a/js/libs/keycloak-js/dist/keycloak.d.ts b/js/libs/keycloak-js/dist/keycloak.d.ts index 6052af7848..075082c397 100644 --- a/js/libs/keycloak-js/dist/keycloak.d.ts +++ b/js/libs/keycloak-js/dist/keycloak.d.ts @@ -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} diff --git a/js/libs/keycloak-js/src/keycloak.js b/js/libs/keycloak-js/src/keycloak.js index 52b9e6a689..388e7541ba 100755 --- a/js/libs/keycloak-js/src/keycloak.js +++ b/js/libs/keycloak-js/src/keycloak.js @@ -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;