index.js
function Keycloak (config, keycloakConfig) {
  // If keycloakConfig is null, Config() will search for `keycloak.json`.
  this.config = new Config(keycloakConfig);

  this.grantManager = new GrantManager(this.config);

  this.stores = [ BearerStore ];

  if (!config) {
    throw new Error('Adapter configuration must be provided.');
  }

  // Add the custom scope value
  this.config.scope = config.scope;

  if (config && config.store && config.cookies) {
    throw new Error('Either `store` or `cookies` may be set, but not both');
  }

  if (config && config.store) {
    this.stores.push(new SessionStore(config.store));
  } else if (config && config.cookies) {
    this.stores.push(CookieStore);
  }

  this.config.idpHint = config.idpHint;
}
function Keycloak (config, keycloakConfig) {
  // If keycloakConfig is null, Config() will search for `keycloak.json`.
  this.config = new Config(keycloakConfig);

  this.grantManager = new GrantManager(this.config);

  this.stores = [ BearerStore ];

  if (!config) {
    throw new Error('Adapter configuration must be provided.');
  }

  // Add the custom scope value
  this.config.scope = config.scope;

  if (config && config.store && config.cookies) {
    throw new Error('Either `store` or `cookies` may be set, but not both');
  }

  if (config && config.store) {
    this.stores.push(new SessionStore(config.store));
  } else if (config && config.cookies) {
    this.stores.push(CookieStore);
  }

  this.config.idpHint = config.idpHint;
}
Instantiate a Keycloak.

The `config` and `keycloakConfig` hashes are both optional.

The `config` hash, if provided, may include either `store`, pointing
to the actual session-store used by your application, or `cookies`
with boolean `true` as the value to support using cookies as your
authentication store.

A session-based store is recommended, as it allows more assured control
from the Keycloak console to explicitly logout some or all sessions.

In all cases, also, authentication through a Bearer authentication
header is supported for non-interactive APIs.

The `keycloakConfig` object, by default, is populated by the contents of
a `keycloak.json` file installed alongside your application, copied from
the Keycloak administration console when you provision your application.

@constructor

@param      {Object}    config          Configuration for the Keycloak connector.
@param      {Object}    keycloakConfig  Keycloak-specific configuration.

@return     {Keycloak}  A constructed Keycloak object.