Creating Elasticsearch indices using REST api protected by SHIELD

     I want to create a template where user going to create indices in Elasticsearch.
    We are asked to use plain javascript, and our ES is protected by SHIELD.
    So how create ES index using REST api in Javascript.

       My major problem is how to authenticate ES users?