> For the complete documentation index, see [llms.txt](https://t1t.gitbook.io/t1c-js-guide-v3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://t1t.gitbook.io/t1c-js-guide-v3/v3.1.4/configuration.md).

# Configuration

## Introduction

In order to use the JS-SDK, the library must be initialised with an api-key. The api-key is a key received upon subscription. The JS-SDK is a client library for web based consumers. As a reminder, the T1C can be used from a native applications context using a native client, or addressing directly the T1C interface.\
In order to work with an api-key in a browser context, 2 type of consumers can be distinguished:

* SPA (Single Page Application) integration: this is a web application without any back-end
* Web Application integration: this is a web application with a back-end implementation

For an SPA, an api-key (thus the access token to the Distribution Service) is considered **unsafe** in a browser context. For SPA's, Trust1Team configures extra security measures on infrastructure level. A mutual authentication is required and additional policies are applied (IP restriction policy, ...).

The api-key must be translated into an JWT token in order to enable communication with the T1C.

## Initialise the client library

To initialise the JavaScript client library, the library must be loaded into your HTML page:

```markup
<script src="../T1CSdk.js" charset="utf-8"></script>
```

Once loaded, the script will expose a GCLLib global. This global will allow you to create a `GCLConfig`:

```
var config = new T1CSdk.T1CConfig(configOptions);
```

The `GCLConfigOptions` object will allow you to specify and/or override the configuration to be used. Configuration options can be found in the `Configuration Options` below. You can create a `GCLConfigOptions` as follows:

```javascript
var configOptions = new T1CSdk.T1CConfigOptions(
        environment.t1cApiUrl,
        environment.t1cApiPort,
        environment.t1cProxyUrl,
        environment.t1cProxyPort,
        environment.t1cDSUrl,
        environment.jwt,
  );
```

Now that we have a configuration, we can initialise the client library. The following example creates a Promise that will resolve with an instance of a `T1CClient`:

```javascript
T1CSdk.T1CClient.initialize(config).then(res => {
        client = res;
        console.log("Client config: ", client.localConfig)
        core = client.core();
    }, err => {});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://t1t.gitbook.io/t1c-js-guide-v3/v3.1.4/configuration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
