crisp-api 10.0.17 → 10.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/README.md +1 -1
- package/dist/crisp.d.ts +8 -2
- package/dist/crisp.js +15 -6
- package/dist/resources/PluginConnect.d.ts +4 -0
- package/lib/crisp.ts +18 -3
- package/lib/resources/PluginConnect.ts +5 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
## v10.0.18
|
|
5
|
+
|
|
6
|
+
* Added the new `CrispClient.setCustomHeaders` method to set custom headers for all API requests.
|
|
7
|
+
|
|
4
8
|
## v10.0.17
|
|
5
9
|
|
|
6
|
-
* Add `stamped` to `ConversationMessage
|
|
10
|
+
* Add `stamped` to `ConversationMessage`.
|
|
7
11
|
|
|
8
12
|
## v10.0.16
|
|
9
13
|
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ The Crisp API Node wrapper. Authenticate, send messages, fetch conversations, ac
|
|
|
6
6
|
|
|
7
7
|
Copyright 2025 Crisp IM SAS. See LICENSE for copying information.
|
|
8
8
|
|
|
9
|
-
* **📝 Implements**: [REST API Reference (V1)](https://docs.crisp.chat/references/rest-api/v1/) at revision:
|
|
9
|
+
* **📝 Implements**: [REST API Reference (V1)](https://docs.crisp.chat/references/rest-api/v1/) at revision: 22/11/2025
|
|
10
10
|
* **😘 Maintainers**: [@baptistejamin](https://github.com/baptistejamin), [@eliottvincent](https://github.com/eliottvincent), [@valeriansaliou](https://github.com/valeriansaliou)
|
|
11
11
|
|
|
12
12
|
## Installation
|
package/dist/crisp.d.ts
CHANGED
|
@@ -22,9 +22,9 @@ interface CrispAuth {
|
|
|
22
22
|
* CLASSES
|
|
23
23
|
***************************************************************************/
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Crisp
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
declare class Crisp {
|
|
28
28
|
bucket: BucketServiceInterface;
|
|
29
29
|
media: MediaServiceInterface;
|
|
30
30
|
plugin: PluginServiceInterface;
|
|
@@ -46,6 +46,7 @@ export declare class Crisp {
|
|
|
46
46
|
mode: RTM_MODES;
|
|
47
47
|
};
|
|
48
48
|
protected _useragent: string;
|
|
49
|
+
protected _customHeaders: Record<string, string>;
|
|
49
50
|
protected _emitter: Emitter<Record<import("mitt").EventType, unknown>>;
|
|
50
51
|
protected _socket: Socket | null;
|
|
51
52
|
protected _loopback: Emitter<Record<string, unknown>> | null;
|
|
@@ -69,6 +70,10 @@ export declare class Crisp {
|
|
|
69
70
|
* Sets the RTM channel mode (ie. WebSockets or Web Hooks)
|
|
70
71
|
*/
|
|
71
72
|
setRtmMode(mode: "websockets" | "webhooks"): void;
|
|
73
|
+
/**
|
|
74
|
+
* Sets custom headers to be included in all API requests
|
|
75
|
+
*/
|
|
76
|
+
setCustomHeaders(headers: Record<string, string>): void;
|
|
72
77
|
/**
|
|
73
78
|
* Sets the authentication tier
|
|
74
79
|
*/
|
|
@@ -176,4 +181,5 @@ export declare class Crisp {
|
|
|
176
181
|
* EXPORTS
|
|
177
182
|
***************************************************************************/
|
|
178
183
|
export * from "./resources";
|
|
184
|
+
export { Crisp };
|
|
179
185
|
export default Crisp;
|
package/dist/crisp.js
CHANGED
|
@@ -45,7 +45,7 @@ const AVAILABLE_RTM_MODES = [
|
|
|
45
45
|
"websockets",
|
|
46
46
|
"webhooks"
|
|
47
47
|
];
|
|
48
|
-
const VERSION = "10.0.
|
|
48
|
+
const VERSION = "10.0.18";
|
|
49
49
|
// Base configuration
|
|
50
50
|
const DEFAULT_REQUEST_TIMEOUT = 10000;
|
|
51
51
|
const DEFAULT_SOCKET_TIMEOUT = 10000;
|
|
@@ -167,7 +167,7 @@ const services = {
|
|
|
167
167
|
* CLASSES
|
|
168
168
|
***************************************************************************/
|
|
169
169
|
/**
|
|
170
|
-
*
|
|
170
|
+
* Crisp
|
|
171
171
|
*/
|
|
172
172
|
class Crisp {
|
|
173
173
|
/**
|
|
@@ -193,6 +193,7 @@ class Crisp {
|
|
|
193
193
|
mode: DEFAULT_RTM_MODE
|
|
194
194
|
};
|
|
195
195
|
this._useragent = (DEFAULT_USERAGENT_PREFIX + VERSION);
|
|
196
|
+
this._customHeaders = {};
|
|
196
197
|
this._emitter = (0, mitt_1.default)();
|
|
197
198
|
this._socket = null;
|
|
198
199
|
this._loopback = null;
|
|
@@ -237,6 +238,17 @@ class Crisp {
|
|
|
237
238
|
AVAILABLE_RTM_MODES.join(", "));
|
|
238
239
|
}
|
|
239
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Sets custom headers to be included in all API requests
|
|
243
|
+
*/
|
|
244
|
+
setCustomHeaders(headers) {
|
|
245
|
+
if (typeof headers === "object" && headers !== null) {
|
|
246
|
+
this._customHeaders = headers;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
throw new Error("[Crisp] setCustomHeaders: parameter headers should be an object");
|
|
250
|
+
}
|
|
251
|
+
}
|
|
240
252
|
/**
|
|
241
253
|
* Sets the authentication tier
|
|
242
254
|
*/
|
|
@@ -658,10 +670,7 @@ class Crisp {
|
|
|
658
670
|
let requestParameters = {
|
|
659
671
|
responseType: "json",
|
|
660
672
|
timeout: DEFAULT_REQUEST_TIMEOUT,
|
|
661
|
-
headers: {
|
|
662
|
-
"User-Agent": this._useragent,
|
|
663
|
-
"X-Crisp-Tier": this.auth.tier
|
|
664
|
-
},
|
|
673
|
+
headers: Object.assign({ "User-Agent": this._useragent, "X-Crisp-Tier": this.auth.tier }, this._customHeaders),
|
|
665
674
|
throwHttpErrors: false
|
|
666
675
|
};
|
|
667
676
|
// Add authorization?
|
|
@@ -21,10 +21,14 @@ export type PluginConnectWebsitesSince = {
|
|
|
21
21
|
};
|
|
22
22
|
export type PluginConnectEndpoints = {
|
|
23
23
|
socket?: PluginConnectEndpointsSocket;
|
|
24
|
+
rescue?: PluginConnectEndpointsRescue;
|
|
24
25
|
};
|
|
25
26
|
export type PluginConnectEndpointsSocket = {
|
|
26
27
|
app?: string;
|
|
27
28
|
};
|
|
29
|
+
export type PluginConnectEndpointsRescue = {
|
|
30
|
+
socket?: PluginConnectEndpointsSocket;
|
|
31
|
+
};
|
|
28
32
|
/**************************************************************************
|
|
29
33
|
* CLASSES
|
|
30
34
|
***************************************************************************/
|
package/lib/crisp.ts
CHANGED
|
@@ -194,9 +194,9 @@ interface CrispAuth {
|
|
|
194
194
|
***************************************************************************/
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
|
-
*
|
|
197
|
+
* Crisp
|
|
198
198
|
*/
|
|
199
|
-
|
|
199
|
+
class Crisp {
|
|
200
200
|
public bucket: BucketServiceInterface = (
|
|
201
201
|
new Bucket() as unknown as BucketServiceInterface
|
|
202
202
|
);
|
|
@@ -240,6 +240,8 @@ export class Crisp {
|
|
|
240
240
|
|
|
241
241
|
protected _useragent = (DEFAULT_USERAGENT_PREFIX + VERSION);
|
|
242
242
|
|
|
243
|
+
protected _customHeaders: Record<string, string> = {};
|
|
244
|
+
|
|
243
245
|
protected _emitter = mitt();
|
|
244
246
|
|
|
245
247
|
protected _socket: Socket | null = null;
|
|
@@ -297,6 +299,17 @@ export class Crisp {
|
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
301
|
|
|
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
|
+
|
|
300
313
|
/**
|
|
301
314
|
* Sets the authentication tier
|
|
302
315
|
*/
|
|
@@ -866,7 +879,8 @@ export class Crisp {
|
|
|
866
879
|
|
|
867
880
|
headers: {
|
|
868
881
|
"User-Agent": this._useragent,
|
|
869
|
-
"X-Crisp-Tier": this.auth.tier
|
|
882
|
+
"X-Crisp-Tier": this.auth.tier,
|
|
883
|
+
...this._customHeaders
|
|
870
884
|
},
|
|
871
885
|
|
|
872
886
|
throwHttpErrors: false
|
|
@@ -1003,4 +1017,5 @@ export class Crisp {
|
|
|
1003
1017
|
***************************************************************************/
|
|
1004
1018
|
|
|
1005
1019
|
export * from "@/resources";
|
|
1020
|
+
export { Crisp };
|
|
1006
1021
|
export default Crisp;
|
|
@@ -35,12 +35,17 @@ export type PluginConnectWebsitesSince = {
|
|
|
35
35
|
|
|
36
36
|
export type PluginConnectEndpoints = {
|
|
37
37
|
socket?: PluginConnectEndpointsSocket;
|
|
38
|
+
rescue?: PluginConnectEndpointsRescue;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
export type PluginConnectEndpointsSocket = {
|
|
41
42
|
app?: string;
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
export type PluginConnectEndpointsRescue = {
|
|
46
|
+
socket?: PluginConnectEndpointsSocket;
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
/**************************************************************************
|
|
45
50
|
* CLASSES
|
|
46
51
|
***************************************************************************/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crisp-api",
|
|
3
3
|
"description": "Crisp API wrapper for Node - official, maintained by Crisp",
|
|
4
|
-
"version": "10.0.
|
|
4
|
+
"version": "10.0.18",
|
|
5
5
|
"homepage": "https://github.com/crisp-im/node-crisp-api",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@typescript-eslint/eslint-plugin": "8.39.1",
|
|
55
55
|
"tsc-alias": "1.8.16",
|
|
56
|
-
"typescript": "5.9.
|
|
56
|
+
"typescript": "5.9.3",
|
|
57
57
|
"eslint": "9.29.0",
|
|
58
|
-
"eslint-plugin-crisp": "1.
|
|
58
|
+
"eslint-plugin-crisp": "1.2.12",
|
|
59
59
|
"eslint-plugin-jsdoc": "50.8.0",
|
|
60
60
|
"globals": "15.15.0"
|
|
61
61
|
},
|