File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 11Changelog
22=========
33
4+ ## v10.0.18
5+
6+ * Added the new ` CrispClient.setCustomHeaders ` method to set custom headers for all API requests.
7+
48## v10.0.17
59
610* Add ` stamped ` to ` ConversationMessage ` .
Original file line number Diff line number Diff line change @@ -240,6 +240,8 @@ class Crisp {
240240
241241 protected _useragent = ( DEFAULT_USERAGENT_PREFIX + VERSION ) ;
242242
243+ protected _customHeaders : Record < string , string > = { } ;
244+
243245 protected _emitter = mitt ( ) ;
244246
245247 protected _socket : Socket | null = null ;
@@ -297,6 +299,17 @@ class Crisp {
297299 }
298300 }
299301
302+ /**
303+ * Sets custom headers to be included in all API requests
304+ */
305+ setCustomHeaders ( headers : Record < string , string > ) {
306+ if ( typeof headers === "object" && headers !== null ) {
307+ this . _customHeaders = headers ;
308+ } else {
309+ throw new Error ( "[Crisp] setCustomHeaders: parameter headers should be an object" ) ;
310+ }
311+ }
312+
300313 /**
301314 * Sets the authentication tier
302315 */
@@ -866,7 +879,8 @@ class Crisp {
866879
867880 headers : {
868881 "User-Agent" : this . _useragent ,
869- "X-Crisp-Tier" : this . auth . tier
882+ "X-Crisp-Tier" : this . auth . tier ,
883+ ...this . _customHeaders
870884 } ,
871885
872886 throwHttpErrors : false
Original file line number Diff line number Diff line change 11{
22 "name" : " crisp-api" ,
33 "description" : " Crisp API wrapper for Node - official, maintained by Crisp" ,
4- "version" : " 10.0.17 " ,
4+ "version" : " 10.0.18 " ,
55 "homepage" : " https://github.com/crisp-im/node-crisp-api" ,
66 "license" : " MIT" ,
77 "author" : {
You can’t perform that action at this time.
0 commit comments