@cstar.help/js 0.11.0 → 0.12.1
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/README.md +58 -6
- package/dist/auth/index.cjs +10 -10
- package/dist/auth/index.d.cts +4 -4
- package/dist/auth/index.d.ts +4 -4
- package/dist/auth/index.js +10 -10
- package/dist/chat/index.cjs +243 -10
- package/dist/chat/index.d.cts +188 -6
- package/dist/chat/index.d.ts +188 -6
- package/dist/chat/index.js +237 -9
- package/dist/quickhelp/index.cjs +102 -0
- package/dist/quickhelp/index.d.cts +97 -0
- package/dist/quickhelp/index.d.ts +97 -0
- package/dist/quickhelp/index.js +76 -0
- package/package.json +11 -1
- package/dist/index.d.cts +0 -2732
- package/dist/index.d.ts +0 -2732
- package/dist/webhook/index.d.cts +0 -163
- package/dist/webhook/index.d.ts +0 -163
package/dist/webhook/index.d.cts
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/** Metadata: string key-value pairs. Max 50 keys, 40-char keys, 500-char values. */
|
|
2
|
-
type Metadata = Record<string, string>;
|
|
3
|
-
|
|
4
|
-
/** A message on a ticket. */
|
|
5
|
-
interface Message {
|
|
6
|
-
id: string;
|
|
7
|
-
object: 'message';
|
|
8
|
-
sender: 'customer' | 'agent' | 'system';
|
|
9
|
-
content: string;
|
|
10
|
-
senderId: string | null;
|
|
11
|
-
senderName: string | null;
|
|
12
|
-
senderAvatarUrl: string | null;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
mergedFromShortId: string | null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** A cStar support ticket. */
|
|
18
|
-
interface Ticket {
|
|
19
|
-
id: string;
|
|
20
|
-
object: 'ticket';
|
|
21
|
-
title: string;
|
|
22
|
-
priority: 'low' | 'normal' | 'high' | 'urgent';
|
|
23
|
-
status: string;
|
|
24
|
-
customerId: string | null;
|
|
25
|
-
customerName: string | null;
|
|
26
|
-
assignedTo: string | null;
|
|
27
|
-
tags: string[];
|
|
28
|
-
notes: string | null;
|
|
29
|
-
messageCount: number;
|
|
30
|
-
responseDeadline: string | null;
|
|
31
|
-
resolutionDeadline: string | null;
|
|
32
|
-
firstResponseAt: string | null;
|
|
33
|
-
responseTier: string | null;
|
|
34
|
-
resolutionTier: string | null;
|
|
35
|
-
slaPaused: boolean;
|
|
36
|
-
metadata: Metadata;
|
|
37
|
-
createdAt: string;
|
|
38
|
-
closedAt: string | null;
|
|
39
|
-
updatedAt: string;
|
|
40
|
-
/** Present when expand includes 'messages' or on single-ticket GET. */
|
|
41
|
-
messages?: Message[];
|
|
42
|
-
/** Present when expand includes 'customer'. */
|
|
43
|
-
customer?: TicketCustomerSummary | null;
|
|
44
|
-
}
|
|
45
|
-
/** Inline customer summary when expanding on a ticket. */
|
|
46
|
-
interface TicketCustomerSummary {
|
|
47
|
-
id: string;
|
|
48
|
-
object: 'customer';
|
|
49
|
-
name: string;
|
|
50
|
-
email: string;
|
|
51
|
-
sentiment: string;
|
|
52
|
-
status: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** A cStar customer. */
|
|
56
|
-
interface Customer {
|
|
57
|
-
id: string;
|
|
58
|
-
object: 'customer';
|
|
59
|
-
name: string;
|
|
60
|
-
email: string;
|
|
61
|
-
sentiment: string;
|
|
62
|
-
status: string;
|
|
63
|
-
tags: string[];
|
|
64
|
-
notes: string | null;
|
|
65
|
-
customFields: Record<string, unknown>;
|
|
66
|
-
ticketCount: number;
|
|
67
|
-
metadata: Metadata;
|
|
68
|
-
createdAt: string;
|
|
69
|
-
updatedAt: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** A cStar knowledge base article. */
|
|
73
|
-
interface Article {
|
|
74
|
-
id: string;
|
|
75
|
-
object: 'article';
|
|
76
|
-
title: string;
|
|
77
|
-
slug: string | null;
|
|
78
|
-
excerpt: string | null;
|
|
79
|
-
content: string | null;
|
|
80
|
-
categoryId: string | null;
|
|
81
|
-
status: 'draft' | 'published';
|
|
82
|
-
tags: string[];
|
|
83
|
-
notes: string | null;
|
|
84
|
-
viewCount: number;
|
|
85
|
-
useCount: number;
|
|
86
|
-
readTime: string;
|
|
87
|
-
isPublic: boolean;
|
|
88
|
-
publishedAt: string | null;
|
|
89
|
-
metaDescription: string | null;
|
|
90
|
-
metadata: Metadata;
|
|
91
|
-
createdAt: string;
|
|
92
|
-
updatedAt: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** All webhook event types supported by cStar. */
|
|
96
|
-
type WebhookEventType = 'ticket.created' | 'ticket.updated' | 'ticket.closed' | 'ticket.message_added' | 'customer.created' | 'customer.updated' | 'article.created' | 'article.published' | 'article.updated' | 'boss.spawned' | 'boss.defeated' | 'player.level_up' | 'achievement.unlocked' | 'survey.submitted';
|
|
97
|
-
/** A webhook event delivered to your endpoint. */
|
|
98
|
-
interface WebhookEvent<T extends WebhookEventType = WebhookEventType> {
|
|
99
|
-
/** Unique event ID (idempotency key). */
|
|
100
|
-
id: string;
|
|
101
|
-
/** Event type. */
|
|
102
|
-
type: T;
|
|
103
|
-
/** When the event was created (ISO 8601). */
|
|
104
|
-
created_at: string;
|
|
105
|
-
/** Team that owns this event. */
|
|
106
|
-
team_id: string;
|
|
107
|
-
/** Event-specific payload. */
|
|
108
|
-
data: WebhookEventData<T>;
|
|
109
|
-
}
|
|
110
|
-
/** Discriminated union mapping event types to their data payloads. */
|
|
111
|
-
type WebhookEventData<T extends WebhookEventType> = T extends 'ticket.created' | 'ticket.updated' | 'ticket.closed' ? {
|
|
112
|
-
ticket: Ticket;
|
|
113
|
-
} : T extends 'ticket.message_added' ? {
|
|
114
|
-
ticket: Ticket;
|
|
115
|
-
message: Message;
|
|
116
|
-
} : T extends 'customer.created' | 'customer.updated' ? {
|
|
117
|
-
customer: Customer;
|
|
118
|
-
} : T extends 'article.created' | 'article.published' | 'article.updated' ? {
|
|
119
|
-
article: Article;
|
|
120
|
-
} : Record<string, unknown>;
|
|
121
|
-
|
|
122
|
-
/** Thrown when webhook signature verification fails. */
|
|
123
|
-
declare class WebhookSignatureVerificationError extends Error {
|
|
124
|
-
constructor(message: string);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Verify a webhook signature and parse the event (synchronous, Node.js only).
|
|
128
|
-
*
|
|
129
|
-
* Uses Node.js `crypto` module for timing-safe HMAC comparison.
|
|
130
|
-
* For browser/edge environments, use `constructEventAsync()`.
|
|
131
|
-
*
|
|
132
|
-
* @param rawBody - Raw request body as a string (NOT parsed JSON)
|
|
133
|
-
* @param signature - Value of the `X-Signature` header
|
|
134
|
-
* @param secret - Your webhook endpoint's secret (`whsec_*`)
|
|
135
|
-
* @returns Parsed and verified webhook event
|
|
136
|
-
* @throws {WebhookSignatureVerificationError} If verification fails
|
|
137
|
-
*/
|
|
138
|
-
declare function constructEvent(rawBody: string, signature: string, secret: string): WebhookEvent;
|
|
139
|
-
/**
|
|
140
|
-
* Verify a webhook signature and parse the event (async, works everywhere).
|
|
141
|
-
*
|
|
142
|
-
* Uses the Web Crypto API — compatible with browsers, Deno, Cloudflare Workers,
|
|
143
|
-
* and Node.js 18+.
|
|
144
|
-
*
|
|
145
|
-
* @param rawBody - Raw request body as a string (NOT parsed JSON)
|
|
146
|
-
* @param signature - Value of the `X-Signature` header
|
|
147
|
-
* @param secret - Your webhook endpoint's secret (`whsec_*`)
|
|
148
|
-
* @returns Parsed and verified webhook event
|
|
149
|
-
* @throws {WebhookSignatureVerificationError} If verification fails
|
|
150
|
-
*/
|
|
151
|
-
declare function constructEventAsync(rawBody: string, signature: string, secret: string): Promise<WebhookEvent>;
|
|
152
|
-
/**
|
|
153
|
-
* Verify an HMAC-SHA256 signature (synchronous, Node.js only).
|
|
154
|
-
* Uses timing-safe comparison to prevent timing attacks.
|
|
155
|
-
*/
|
|
156
|
-
declare function verifySignature(rawBody: string, signature: string, secret: string): boolean;
|
|
157
|
-
/**
|
|
158
|
-
* Verify an HMAC-SHA256 signature (async, works everywhere).
|
|
159
|
-
* Uses the Web Crypto API with constant-time comparison.
|
|
160
|
-
*/
|
|
161
|
-
declare function verifySignatureAsync(rawBody: string, signature: string, secret: string): Promise<boolean>;
|
|
162
|
-
|
|
163
|
-
export { type WebhookEvent, WebhookSignatureVerificationError, constructEvent, constructEventAsync, verifySignature, verifySignatureAsync };
|
package/dist/webhook/index.d.ts
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/** Metadata: string key-value pairs. Max 50 keys, 40-char keys, 500-char values. */
|
|
2
|
-
type Metadata = Record<string, string>;
|
|
3
|
-
|
|
4
|
-
/** A message on a ticket. */
|
|
5
|
-
interface Message {
|
|
6
|
-
id: string;
|
|
7
|
-
object: 'message';
|
|
8
|
-
sender: 'customer' | 'agent' | 'system';
|
|
9
|
-
content: string;
|
|
10
|
-
senderId: string | null;
|
|
11
|
-
senderName: string | null;
|
|
12
|
-
senderAvatarUrl: string | null;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
mergedFromShortId: string | null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** A cStar support ticket. */
|
|
18
|
-
interface Ticket {
|
|
19
|
-
id: string;
|
|
20
|
-
object: 'ticket';
|
|
21
|
-
title: string;
|
|
22
|
-
priority: 'low' | 'normal' | 'high' | 'urgent';
|
|
23
|
-
status: string;
|
|
24
|
-
customerId: string | null;
|
|
25
|
-
customerName: string | null;
|
|
26
|
-
assignedTo: string | null;
|
|
27
|
-
tags: string[];
|
|
28
|
-
notes: string | null;
|
|
29
|
-
messageCount: number;
|
|
30
|
-
responseDeadline: string | null;
|
|
31
|
-
resolutionDeadline: string | null;
|
|
32
|
-
firstResponseAt: string | null;
|
|
33
|
-
responseTier: string | null;
|
|
34
|
-
resolutionTier: string | null;
|
|
35
|
-
slaPaused: boolean;
|
|
36
|
-
metadata: Metadata;
|
|
37
|
-
createdAt: string;
|
|
38
|
-
closedAt: string | null;
|
|
39
|
-
updatedAt: string;
|
|
40
|
-
/** Present when expand includes 'messages' or on single-ticket GET. */
|
|
41
|
-
messages?: Message[];
|
|
42
|
-
/** Present when expand includes 'customer'. */
|
|
43
|
-
customer?: TicketCustomerSummary | null;
|
|
44
|
-
}
|
|
45
|
-
/** Inline customer summary when expanding on a ticket. */
|
|
46
|
-
interface TicketCustomerSummary {
|
|
47
|
-
id: string;
|
|
48
|
-
object: 'customer';
|
|
49
|
-
name: string;
|
|
50
|
-
email: string;
|
|
51
|
-
sentiment: string;
|
|
52
|
-
status: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** A cStar customer. */
|
|
56
|
-
interface Customer {
|
|
57
|
-
id: string;
|
|
58
|
-
object: 'customer';
|
|
59
|
-
name: string;
|
|
60
|
-
email: string;
|
|
61
|
-
sentiment: string;
|
|
62
|
-
status: string;
|
|
63
|
-
tags: string[];
|
|
64
|
-
notes: string | null;
|
|
65
|
-
customFields: Record<string, unknown>;
|
|
66
|
-
ticketCount: number;
|
|
67
|
-
metadata: Metadata;
|
|
68
|
-
createdAt: string;
|
|
69
|
-
updatedAt: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** A cStar knowledge base article. */
|
|
73
|
-
interface Article {
|
|
74
|
-
id: string;
|
|
75
|
-
object: 'article';
|
|
76
|
-
title: string;
|
|
77
|
-
slug: string | null;
|
|
78
|
-
excerpt: string | null;
|
|
79
|
-
content: string | null;
|
|
80
|
-
categoryId: string | null;
|
|
81
|
-
status: 'draft' | 'published';
|
|
82
|
-
tags: string[];
|
|
83
|
-
notes: string | null;
|
|
84
|
-
viewCount: number;
|
|
85
|
-
useCount: number;
|
|
86
|
-
readTime: string;
|
|
87
|
-
isPublic: boolean;
|
|
88
|
-
publishedAt: string | null;
|
|
89
|
-
metaDescription: string | null;
|
|
90
|
-
metadata: Metadata;
|
|
91
|
-
createdAt: string;
|
|
92
|
-
updatedAt: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** All webhook event types supported by cStar. */
|
|
96
|
-
type WebhookEventType = 'ticket.created' | 'ticket.updated' | 'ticket.closed' | 'ticket.message_added' | 'customer.created' | 'customer.updated' | 'article.created' | 'article.published' | 'article.updated' | 'boss.spawned' | 'boss.defeated' | 'player.level_up' | 'achievement.unlocked' | 'survey.submitted';
|
|
97
|
-
/** A webhook event delivered to your endpoint. */
|
|
98
|
-
interface WebhookEvent<T extends WebhookEventType = WebhookEventType> {
|
|
99
|
-
/** Unique event ID (idempotency key). */
|
|
100
|
-
id: string;
|
|
101
|
-
/** Event type. */
|
|
102
|
-
type: T;
|
|
103
|
-
/** When the event was created (ISO 8601). */
|
|
104
|
-
created_at: string;
|
|
105
|
-
/** Team that owns this event. */
|
|
106
|
-
team_id: string;
|
|
107
|
-
/** Event-specific payload. */
|
|
108
|
-
data: WebhookEventData<T>;
|
|
109
|
-
}
|
|
110
|
-
/** Discriminated union mapping event types to their data payloads. */
|
|
111
|
-
type WebhookEventData<T extends WebhookEventType> = T extends 'ticket.created' | 'ticket.updated' | 'ticket.closed' ? {
|
|
112
|
-
ticket: Ticket;
|
|
113
|
-
} : T extends 'ticket.message_added' ? {
|
|
114
|
-
ticket: Ticket;
|
|
115
|
-
message: Message;
|
|
116
|
-
} : T extends 'customer.created' | 'customer.updated' ? {
|
|
117
|
-
customer: Customer;
|
|
118
|
-
} : T extends 'article.created' | 'article.published' | 'article.updated' ? {
|
|
119
|
-
article: Article;
|
|
120
|
-
} : Record<string, unknown>;
|
|
121
|
-
|
|
122
|
-
/** Thrown when webhook signature verification fails. */
|
|
123
|
-
declare class WebhookSignatureVerificationError extends Error {
|
|
124
|
-
constructor(message: string);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Verify a webhook signature and parse the event (synchronous, Node.js only).
|
|
128
|
-
*
|
|
129
|
-
* Uses Node.js `crypto` module for timing-safe HMAC comparison.
|
|
130
|
-
* For browser/edge environments, use `constructEventAsync()`.
|
|
131
|
-
*
|
|
132
|
-
* @param rawBody - Raw request body as a string (NOT parsed JSON)
|
|
133
|
-
* @param signature - Value of the `X-Signature` header
|
|
134
|
-
* @param secret - Your webhook endpoint's secret (`whsec_*`)
|
|
135
|
-
* @returns Parsed and verified webhook event
|
|
136
|
-
* @throws {WebhookSignatureVerificationError} If verification fails
|
|
137
|
-
*/
|
|
138
|
-
declare function constructEvent(rawBody: string, signature: string, secret: string): WebhookEvent;
|
|
139
|
-
/**
|
|
140
|
-
* Verify a webhook signature and parse the event (async, works everywhere).
|
|
141
|
-
*
|
|
142
|
-
* Uses the Web Crypto API — compatible with browsers, Deno, Cloudflare Workers,
|
|
143
|
-
* and Node.js 18+.
|
|
144
|
-
*
|
|
145
|
-
* @param rawBody - Raw request body as a string (NOT parsed JSON)
|
|
146
|
-
* @param signature - Value of the `X-Signature` header
|
|
147
|
-
* @param secret - Your webhook endpoint's secret (`whsec_*`)
|
|
148
|
-
* @returns Parsed and verified webhook event
|
|
149
|
-
* @throws {WebhookSignatureVerificationError} If verification fails
|
|
150
|
-
*/
|
|
151
|
-
declare function constructEventAsync(rawBody: string, signature: string, secret: string): Promise<WebhookEvent>;
|
|
152
|
-
/**
|
|
153
|
-
* Verify an HMAC-SHA256 signature (synchronous, Node.js only).
|
|
154
|
-
* Uses timing-safe comparison to prevent timing attacks.
|
|
155
|
-
*/
|
|
156
|
-
declare function verifySignature(rawBody: string, signature: string, secret: string): boolean;
|
|
157
|
-
/**
|
|
158
|
-
* Verify an HMAC-SHA256 signature (async, works everywhere).
|
|
159
|
-
* Uses the Web Crypto API with constant-time comparison.
|
|
160
|
-
*/
|
|
161
|
-
declare function verifySignatureAsync(rawBody: string, signature: string, secret: string): Promise<boolean>;
|
|
162
|
-
|
|
163
|
-
export { type WebhookEvent, WebhookSignatureVerificationError, constructEvent, constructEventAsync, verifySignature, verifySignatureAsync };
|