Developers

SDK Configuration

The following section describes all of the configuration parameters and methods that are available for the Search SDK.

Configuration options

The following table shows the available InbentaSearchSDK parameters:

Name Type Default Description
apiURL string null Defines the URL of the search endpoint. If defined, it avoids the initial request to /apis for the sole purpose of getting the URL of the search endpoint when creating the Client using createFromAccessToken.
autoRefresh boolean true Defines whether or not the client gets a new token when the current one expires. If set to false, the client does not automatically call /refreshToken or /auth when the token expires.
connectionEntryPoint string https://api.inbenta.io/ This parameter defines the Inbenta API endpoint where the SDK performs the Auth connection. You can select any available endpoint from the ones defined in Regions and Endpoints.
environment string production Defines the source environment from Search App's knowledge base. It uses an x-inbenta-env header. For more information about this header, see the API Routes.
expirationTime integer null Defines the Unix timestamp when the token should expire. If defined, it avoids the initial request to /refreshToken when creating the Client using createFromAccessToken.
labels object Override the default texts used in components. Each component has its own default labels that can be overriden. For more information, see the components section. See the list of all SDK labels for their customization or translation.
sanitizeOptions object *Sanitize Default Defines the tags, the attributes per tag and the schemes that can be fetched from feeds when included in fetched contents.
skin string space-cowboy Defines the components appearance (skin). You can choose between these options:
  • space-cowboy
  • space-cowboy-wcag
  • ocean-flow
  • tatooine-sunset
  • imperial-black
  • teth-sunrise
  • newtral
For more information, see the CSS Guide.
source string null Source identifier (e.g. facebook, mobile, etc.) used to filter the logs in the Dashboards. It uses an x-inbenta-source header to make API requests.
userType integer 0 Defines the profiles identifier from the Search App's Knowledge Base. It uses an x-inbenta-user-type header to make API requests. For more information about this header, see the API Routes.
compressResponses boolean false Defines whether the Search API returns its responses compressed in gzip format.
Currently, the only endpoint supporting this option is the GET /autocompleter/data endpoint.

Sanitizer

For security reasons, Inbenta escapes several HTML tags. There is a whitelist of these HTML tags, which you can modify.

The default whitelist is below. If you do not specify sanitizeOptions in the build configuration, the default value applies:

    allowedTags: ['h1','h2','h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol',
        'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div',
        'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre','img'],
    allowedAttributes: {
        a: [ 'href', 'name', 'target' ],
        img: [ 'src' ],
        div: ['id', 'class'],
        i: ['class']
    },
    allowedSchemes: [ 'http', 'https', 'ftp', 'mailto' ]

AllowedTags is the list of HTML tags that you can use. AllowedAttributes lists the attributes that you can use in the allowed HTML tags (for example, href in an a tag, or src in an image). HTML classes are blocked by default, but you can add them to the whitelist with the following statement: allowedClasses. AllowedSchemes are the protocols defined in URLs included in href, src and similar attributes. Examples of protocols are HTTP and HTTPS.

Caution

Any change you make to the default whitelist is strictly at your own risk. Inbenta does not recommend the addition of additional tags and will not accept any responsibility or liability for any issue caused by changes in the default whitelist.

The following example includes an additional iframes HTML tag and a test class in the p HTML tag and the scheme data:

config={
  sanitizeOptions : {
    allowedTags: ['h1','h2','h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol',
      'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div',
      'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre','img','iframe'],
    allowedAttributes: {
      a: [ 'href', 'name', 'target' ],
      iframe:['src'],
      img: [ 'src' ]
    },
    allowedClasses: {
      'p': [ 'test']
    },
    allowedSchemes: [ 'http', 'https', 'ftp', 'mailto', 'data' ]
  }
}

Methods

The SDK offers several methods to perform actions.

Name Method Static Description
createFromAccessToken createFromAccessToken(accessToken: String, apiKey: String, config: Object = {}): SDK Yes Creates a new SDK, using the API Key and an access token obtained from the /auth endpoint.
createFromDomainKey createFromDomainKey(domainKey: String, apiKey: String, config: Object = {}): SDK Yes Creates a new SDK, using the API Key and a domain key.
getSessionId getSessionId(): String No Obtains the Session Id of the current session.
setCallbackWhenInvalidAccessToken setCallbackWhenInvalidAccessToken(callback: function) No Allows to provide a custom functionality in case the AccessToken is not valid.