SDK Configuration

Configuration options

Config is an optional parameter.

Caution

Changes to the configuration can affect all the Inbenta components and templates. If you want to add a component with a different configuration, you must create another SDK instance in the same page.

Use the config parameter when you create the session:

var sdk = InbentaKmSDK.createFromAccessToken(access_token:String, inbenta_key:String, config:Object);
Name Type Default Description
accessTokenExpiration string 0 Expiration time returned by the auth endpoint
connectionEntryPoint string https://api.inbenta.io/ This parameter defines the Inbenta API endpoint where the SDK is going to perform the Auth connection. You can choose any available endpoint from the ones defined in Regions and Endpoints.
environment String production Defines source environment from the App's knowledge base. It will be used in client as x-inbenta-env header. For more information about this header, see the API Routes.
labels object {} Override the default texts used in components. Each component has its own default labels that can be overriden. Here is a list of all the default labels.
logIp boolean false Log the user's IP in user info.
logUserAgent boolean false Log the user's user agent in user info.
sanitizeOptions Object *Sanitize Default Defines the allowed tags and the allowed attributes for per tag.
skin String default Defines the components' appearance with CSS files. Its default value is 'default'. For more information, see below.
source string null Defines source of the API calls. Used in client as a x-inbenta-source header. For more information about this header, see the API Routes.
userType integer 0 Defines the profile identifier from the KM App's Knowledge Base. It will be used in client as x-inbenta-user-type header to make API requests. For more information about this header, see the API Routes.

Sanitizer

For security reasons, Inbenta escapes several HTML tags. A whitelist of these HTML tags exists, 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']
    },
    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 URL schemes in cases where href, src, etc.

Caution

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

The following example includes a 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' ]
  }
}

SDK Methods

Name Description
untilReady() (deprecated) Since version 1.21.0 it returns a resolved promise. Before it waits until a valid accessToken and valid sessionToken is generated.

Interceptors

See the Interceptors section.