Skip to content

Commit

Permalink
Merge pull request #18 from warrant-dev/PassClientKeyInRequestHeader
Browse files Browse the repository at this point in the history
Pass client key in request header if included in config
  • Loading branch information
stanleyphu authored Mar 4, 2024
2 parents ddd4f4b + 0f75d60 commit 21ec6f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/HttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface HttpClient {
export interface HttpClientConfig {
sessionToken: string;
baseUrl: string;
clientKey: string;
}

export interface HttpClientRequestOptions {
Expand Down Expand Up @@ -65,6 +66,7 @@ export default class ApiClient implements HttpClient {
const headers = {
"User-Agent": `warrant-js/${PACKAGE_VERSION}`,
Authorization: `Bearer ${this.config.sessionToken}`,
"Warrant-Client-Key": this.config.clientKey,
};

if (requestOptions?.sessionToken) {
Expand Down
1 change: 1 addition & 0 deletions src/WarrantClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class WarrantClient {
this.httpClient = new ApiClient({
sessionToken: this.config.sessionToken,
baseUrl: this.config.endpoint || API_URL_BASE,
clientKey: this.config.clientKey,
});
}

Expand Down

0 comments on commit 21ec6f7

Please sign in to comment.