@cstar.help/js 0.16.1 → 0.17.2

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 CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Official TypeScript SDK for the [cStar](https://cstar.help) customer support platform.
4
4
 
5
- - **Zero dependencies** — works with Node.js 18+ native `fetch`
6
- - **TypeScript-first** — full type definitions included
7
- - **Six entry points** — tree-shake what you don't need
8
- - **ESM + CJS** — works everywhere
5
+ - **Native fetch** for HTTP, Supabase for realtime
6
+ - **TypeScript-first**, with full type definitions included
7
+ - **Focused entry points** for the part of cStar you're building with
8
+ - **ESM + CJS** exports
9
9
 
10
10
  ## Install
11
11
 
@@ -17,37 +17,26 @@ npm install @cstar.help/js
17
17
 
18
18
  ## Which SDK Do I Need?
19
19
 
20
- cStar has one package with **six entry points**, each designed for a different context:
20
+ cStar has one package with separate entry points for different workflows. Start here:
21
21
 
22
- | Import | Use Case | Runs On | Auth Required | Key Type |
23
- | -------------------------- | ----------------------------------------- | ----------------- | ------------- | -------------------- |
24
- | `@cstar.help/js` | **Admin dashboard / backend integration** | Server only | Yes | Secret (`sk_*`) |
25
- | `@cstar.help/js/chat` | Customer chat widget | Browser | Yes | Publishable (`pk_*`) |
26
- | `@cstar.help/js/library` | Public knowledge base | Browser or server | No | None |
27
- | `@cstar.help/js/community` | Public community forum | Browser or server | No | None |
28
- | `@cstar.help/js/webhook` | Webhook signature verification | Server only | No | Signing secret |
29
- | `@cstar.help/js/auth` | Authentication utilities | Server only | Yes | Secret (`sk_*`) |
22
+ | Import | Use Case | Runs On | Auth Required | Key Type |
23
+ | -------------------------- | ----------------------------------------- | ----------------- | ------------- | ------------------------ |
24
+ | `@cstar.help/js` | **Admin dashboard / backend integration** | Server only | Yes | Secret (`sk_*`) |
25
+ | `@cstar.help/js/chat` | Customer chat widget | Browser | Yes | HMAC or customer session |
26
+ | `@cstar.help/js/library` | Public knowledge base | Browser or server | No | None |
27
+ | `@cstar.help/js/community` | Public community forum | Browser or server | No | None |
28
+ | `@cstar.help/js/webhook` | Webhook signature verification | Server only | No | Signing secret |
29
+ | `@cstar.help/js/auth` | Authentication utilities | Server only | Yes | Secret (`sk_*`) |
30
30
 
31
31
  ### The Security Model
32
32
 
33
- cStar uses **two key types** to control access — the same pattern as Stripe:
33
+ The server API and customer chat authenticate differently:
34
34
 
35
- ```
36
- Secret keys (sk_live_*, sk_test_*)
37
- ├── Full CRUD on all resources
38
- ├── Settings, billing, analytics, game system
39
- ├── Team member management, audit log
40
- ├── AI actions, automations, SLA rules
41
- └── NEVER expose in client-side code
42
-
43
- Publishable keys (pk_live_*, pk_test_*)
44
- ├── Read-only on public data (tickets, customers, articles)
45
- ├── Used by the chat widget for customer-facing features
46
- ├── Safe to include in browser bundles
47
- └── Cannot write, delete, or access sensitive endpoints
48
- ```
35
+ - **Secret API keys** (`sk_live_*`, `sk_test_*`) authorize team API operations within the key's permissions. Keep them on your server.
36
+ - **Publishable API keys** (`pk_live_*`, `pk_test_*`) provide limited read-only access to API endpoints that accept them. They do not identify a customer or authorize customer chat.
37
+ - **ChatClient** takes a `teamSlug`, then authenticates a customer through HMAC identity verification or a customer session. It has no API-key option. Keep HMAC signing secrets on your server too.
49
38
 
50
- > **Rule of thumb**: If you're building a custom support dashboard for your team, use `CStarClient` with a secret key on your backend. If you're adding chat to your website, use `ChatClient` with a publishable key in the browser.
39
+ > Building a support dashboard? Use `CStarClient` on your backend. Adding a conversation to your website? Use `ChatClient` and one of the customer authentication options below.
51
40
 
52
41
  ---
53
42
 
@@ -198,59 +187,95 @@ const { data: searchResults } = await cstar.search.query({
198
187
 
199
188
  ## Client-Side: Chat Widget SDK
200
189
 
201
- Build custom chat experiences in the browser. Uses a publishable key — safe for frontend code.
190
+ Build a chat experience that feels at home on your site. `ChatClient` handles customer conversations in the browser without a team API key.
202
191
 
203
192
  The chat client supports two authentication modes:
204
193
 
205
- - **HMAC** — your server signs the customer payload with the team's signing secret. Best for sites where users are already authenticated server-side.
206
- - **Session** — the customer signs in directly with email/password (or magic link). Best for standalone widgets and customer portals where there's no host-app session to bridge.
194
+ - **HMAC:** your authenticated backend signs the customer's identity with the team's signing secret. Use this when your site already knows who's signed in.
195
+ - **Session:** sign in with cStar customer credentials, or provide an existing cStar customer access token. Use this for a standalone widget or customer portal.
207
196
 
208
- You don't have to pick the mode up-front. The first response from any cstar endpoint includes an `X-Cstar-Auth-Mode` header, which the SDK caches; `chat.getAuthMode()` returns `'hmac'`, `'session'`, or `null` after the first call.
197
+ Choose the flow supported by your team's widget configuration. `chat.getAuthMode()` returns `'hmac'`, `'session'`, or `null` before authentication or after disconnecting. A session login sets the session mode; the SDK also reads the server's `X-Cstar-Auth-Mode` response header.
209
198
 
210
199
  ### HMAC
211
200
 
201
+ Create `/api/support/identity` on your own backend. It must derive the customer from the authenticated user and return `{ customer, signature }` using your team's signing secret. Send that exact payload to cStar; generating a new timestamp in the browser changes the signed data. The [identity guide](https://cstar.help/developers/sdk/js/chat#identify) shows the signing contract.
202
+
212
203
  ```typescript
213
- import { ChatClient } from '@cstar.help/js/chat';
204
+ import { ChatClient, type IdentifyParams } from '@cstar.help/js/chat';
214
205
 
215
206
  const chat = new ChatClient({ teamSlug: 'acme' });
216
-
217
- await chat.identify(
218
- { externalId: 'usr_123', email: 'jane@example.com', name: 'Jane', timestamp: Date.now() / 1000 },
219
- hmacSignature
220
- );
207
+ const response = await fetch('/api/support/identity', { credentials: 'same-origin' });
208
+ if (!response.ok) throw new Error('Could not verify your support identity');
209
+
210
+ const { customer, signature } = (await response.json()) as {
211
+ customer: IdentifyParams;
212
+ signature: string;
213
+ };
214
+ await chat.identify(customer, signature);
221
215
  ```
222
216
 
223
217
  ### Session (email/password)
224
218
 
225
219
  ```typescript
220
+ import { ChatClient } from '@cstar.help/js/chat';
221
+
226
222
  const chat = new ChatClient({ teamSlug: 'acme' });
227
223
 
228
- // Login with credentials — returns the customer + tokens
229
- const { customer, accessToken, refreshToken } = await chat.loginWithCredentials(
230
- 'jane@example.com',
231
- 'hunter2'
232
- );
224
+ // Use the values from your customer's sign-in form.
225
+ const { customer, teamId } = await chat.loginWithCredentials({
226
+ email: 'jane@example.com',
227
+ password: 'your-customer-password'
228
+ });
229
+ console.log(`Hello, ${customer.name ?? customer.email}!`, teamId);
230
+ ```
231
+
232
+ The client keeps the access token internally. The public result contains `customer` and `teamId`, not access or refresh tokens. This signs in an existing customer; it does not create an account.
233
+
234
+ ### Session (existing customer token)
235
+
236
+ Pass an existing cStar customer token as an object. A token from an unrelated Supabase project does not establish a cStar customer session. Include the cStar team UUID when your application has it. Otherwise the client resolves its configured team slug before message, community and realtime requests.
233
237
 
234
- // Or rehydrate from previously stored tokens
235
- await chat.loginWithSession(accessToken, refreshToken);
238
+ ```typescript
239
+ import { ChatClient, type LoginWithSessionParams } from '@cstar.help/js/chat';
240
+
241
+ async function connectCustomerSession(session: LoginWithSessionParams) {
242
+ const chat = new ChatClient({ teamSlug: 'acme' });
243
+ await chat.loginWithSession(session); // { accessToken, teamId?, customerName? }
244
+ return chat;
245
+ }
236
246
  ```
237
247
 
238
248
  ### Once authenticated (either mode)
239
249
 
240
250
  ```typescript
241
- const { tickets } = await chat.tickets.list();
242
- await chat.messages.send('tkt_abc123', 'Thanks for the help!');
243
-
244
- const unsubscribe = chat.onMessage('tkt_abc123', (message) => {
245
- console.log(`${message.sender_name}: ${message.content}`);
246
- });
251
+ const { data: tickets, pagination } = await chat.tickets.list();
252
+ console.log(`${tickets.length} conversations`, pagination.hasMore);
253
+
254
+ // Use a ticket ID returned by the customer API.
255
+ const ticket = tickets[0];
256
+ let unsubscribe = () => {};
257
+ if (ticket) {
258
+ const history = await chat.messages.list(ticket.id);
259
+ console.log(history); // Message[]
260
+ await chat.messages.send(ticket.id, 'Thanks for the help!');
261
+
262
+ unsubscribe = chat.onMessage(ticket.id, (message) => {
263
+ console.log(`${message.sender_name}: ${message.content}`);
264
+ });
265
+ }
247
266
 
248
- chat.disconnect();
267
+ // Wire this to your UI's close/unmount handler and account-change cleanup.
268
+ function closeChat() {
269
+ unsubscribe();
270
+ chat.disconnect();
271
+ }
249
272
  ```
250
273
 
251
274
  ### Typed errors
252
275
 
253
- Every `ChatClient` request throws a typed subclass of `ChatClientError` on failure. Each carries a `requestId` (from the `X-Request-Id` response header) so customer support can correlate against server logs.
276
+ HTTP and network failures use typed subclasses of `ChatClientError`. A server response may provide a `requestId` through the `X-Request-Id` header; it is `null` when unavailable. Other failures, such as malformed response JSON, can still throw ordinary errors.
277
+
278
+ A lost response may follow a successful send. Keep the unsent text available and check the conversation before offering another send. Do not automatically resend a message because a network or server error occurred.
254
279
 
255
280
  ```typescript
256
281
  import {
@@ -265,15 +290,17 @@ try {
265
290
  await chat.identify(customer, signature);
266
291
  } catch (err) {
267
292
  if (err instanceof ChatClientAuthError) {
268
- // 401 / 403 — bad signature, expired token, wrong team
293
+ // Authentication failed or the active customer session changed.
269
294
  } else if (err instanceof ChatClientRateLimitError) {
270
- // 429 — back off for err.retryAfter seconds
295
+ // 429: respect err.retryAfter when the server supplies it.
271
296
  } else if (err instanceof ChatClientServerError) {
272
- // 5xx — usually transient, retry with backoff
297
+ // Server failure: keep the draft and check the conversation.
273
298
  } else if (err instanceof ChatClientNetworkError) {
274
- // fetch() itself failed — DNS, offline, CORS — see err.originalError
299
+ // Network failure: err.originalError has the underlying cause.
275
300
  } else if (err instanceof ChatClientError) {
276
301
  console.log('Error', err.code, err.statusCode, 'requestId:', err.requestId);
302
+ } else {
303
+ throw err;
277
304
  }
278
305
  }
279
306
  ```
@@ -349,11 +376,24 @@ const cstar = new CStarClient({
349
376
  teamId: 'tm_...', // Required — your team ID
350
377
  baseUrl: 'https://...', // Optional — defaults to https://www.cstar.help
351
378
  version: '2026-03-01', // Optional — API version header
352
- maxRetries: 3, // Optional — retry attempts for 5xx/429
379
+ maxRetries: 3, // Optional — retry attempts for retry-safe failures and 429
353
380
  timeout: 30000 // Optional — request timeout in ms
354
381
  });
355
382
  ```
356
383
 
384
+ Reads retry network errors and server errors automatically. POST and PATCH
385
+ requests retry those failures only when you pass `idempotencyKey` in the existing
386
+ request options. A lost response may follow a successful write, so the SDK
387
+ otherwise surfaces the error without repeating the mutation. Rate-limited
388
+ requests still retry because the API rejects them before executing the operation.
389
+
390
+ ```typescript
391
+ await cstar.tickets.create(
392
+ { title: 'Cannot reset password', customerId: 'cus_...' },
393
+ { idempotencyKey: 'support-issue-123' }
394
+ );
395
+ ```
396
+
357
397
  ## Test Mode
358
398
 
359
399
  Test mode is auto-detected from your API key prefix:
@@ -411,7 +451,7 @@ const { data: ticket } = await cstar.tickets.create(
411
451
 
412
452
  ## Requirements
413
453
 
414
- - Node.js 18+ (for native `fetch` and `AbortSignal.timeout`)
454
+ - Node.js 22+ (matching the supported Supabase dependency)
415
455
  - TypeScript 5.0+ (for type definitions)
416
456
 
417
457
  ## License
@@ -1,3 +1,5 @@
1
+ export { A as ApiErrorBody, C as CStarAuthenticationError, a as CStarConflictError, b as CStarError, c as CStarFeatureDisabledError, d as CStarNotFoundError, e as CStarPermissionError, f as CStarRateLimitError, g as CStarRealtimeUnavailableError, h as CStarServerError, i as CStarValidationError, E as ErrorType, p as parseError, j as parsePublicError } from '../errors-b5A4wfAg.cjs';
2
+
1
3
  /** Configuration for the AuthClient. */
2
4
  interface AuthConfig {
3
5
  /** Team slug (e.g., 'acme'). Identifies which team's customers to authenticate. */
@@ -56,403 +58,6 @@ interface AuthSession {
56
58
  refreshToken: string;
57
59
  }
58
60
 
59
- /**
60
- * Error classes for the cStar SDK.
61
- *
62
- * NEW-v3-01 — Cross-subpath instanceof identity.
63
- *
64
- * Each public subpath (`/library`, `/auth`, `/community`, `/quickhelp`, ...)
65
- * is bundled as a separate tsup entry with `splitting: false`, so each one
66
- * carries its own copy of this module. Without deduplication, errors thrown
67
- * by `LibraryClient` carry the LibraryClient-bundled `CStarError` class —
68
- * not the one a consumer imports from `@cstar.help/js`. That makes
69
- * `instanceof CStarError` checks fail silently, invalidating every "did the
70
- * SDK throw a typed cStar error?" branch in user code.
71
- *
72
- * Fix: register each class on a `Symbol.for(...)` slot of `globalThis`. The
73
- * symbol is realm-shared, so every bundled copy of this module resolves to
74
- * the SAME class identity at runtime — the first copy to load wins, and all
75
- * subsequent copies surface the canonical class via the same slot. The
76
- * inline `Impl` definitions are only used as the seed for the very first
77
- * copy to register. Internal `parseError` / `parsePublicError` reference the
78
- * EXPORTED canonical names so instances they construct also land on the
79
- * canonical class.
80
- */
81
- /** Error type constants matching the cStar API. */
82
- declare const ErrorType: {
83
- readonly AUTHENTICATION_ERROR: "authentication_error";
84
- readonly PERMISSION_ERROR: "permission_error";
85
- readonly INVALID_REQUEST_ERROR: "invalid_request_error";
86
- readonly NOT_FOUND_ERROR: "not_found_error";
87
- readonly CONFLICT_ERROR: "conflict_error";
88
- readonly RATE_LIMIT_ERROR: "rate_limit_error";
89
- readonly FEATURE_NOT_CONFIGURED: "feature_not_configured";
90
- readonly API_ERROR: "api_error";
91
- readonly SERVER_ERROR: "server_error";
92
- };
93
- /** Shape of the error object returned by the cStar API. */
94
- interface ApiErrorBody {
95
- type: string;
96
- code: string;
97
- message: string;
98
- param?: string;
99
- doc_url: string;
100
- request_id?: string;
101
- feature?: string;
102
- enable_url?: string;
103
- }
104
- /** Base error class for all cStar API errors. */
105
- declare const CStarErrorImpl: {
106
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
107
- readonly type: string;
108
- readonly code: string;
109
- readonly param?: string;
110
- readonly docUrl: string;
111
- readonly requestId?: string;
112
- readonly statusCode: number;
113
- name: string;
114
- message: string;
115
- stack?: string;
116
- };
117
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
118
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
119
- stackTraceLimit: number;
120
- };
121
- declare const CStarAuthenticationErrorImpl: {
122
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
123
- readonly type: string;
124
- readonly code: string;
125
- readonly param?: string;
126
- readonly docUrl: string;
127
- readonly requestId?: string;
128
- readonly statusCode: number;
129
- name: string;
130
- message: string;
131
- stack?: string;
132
- };
133
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
134
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
135
- stackTraceLimit: number;
136
- };
137
- declare const CStarRateLimitErrorImpl: {
138
- new (messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number): {
139
- readonly retryAfter: number;
140
- readonly type: string;
141
- readonly code: string;
142
- readonly param?: string;
143
- readonly docUrl: string;
144
- readonly requestId?: string;
145
- readonly statusCode: number;
146
- name: string;
147
- message: string;
148
- stack?: string;
149
- };
150
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
151
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
152
- stackTraceLimit: number;
153
- };
154
- declare const CStarNotFoundErrorImpl: {
155
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
156
- readonly type: string;
157
- readonly code: string;
158
- readonly param?: string;
159
- readonly docUrl: string;
160
- readonly requestId?: string;
161
- readonly statusCode: number;
162
- name: string;
163
- message: string;
164
- stack?: string;
165
- };
166
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
167
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
168
- stackTraceLimit: number;
169
- };
170
- declare const CStarValidationErrorImpl: {
171
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
172
- readonly type: string;
173
- readonly code: string;
174
- readonly param?: string;
175
- readonly docUrl: string;
176
- readonly requestId?: string;
177
- readonly statusCode: number;
178
- name: string;
179
- message: string;
180
- stack?: string;
181
- };
182
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
183
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
184
- stackTraceLimit: number;
185
- };
186
- declare const CStarPermissionErrorImpl: {
187
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
188
- readonly type: string;
189
- readonly code: string;
190
- readonly param?: string;
191
- readonly docUrl: string;
192
- readonly requestId?: string;
193
- readonly statusCode: number;
194
- name: string;
195
- message: string;
196
- stack?: string;
197
- };
198
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
199
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
200
- stackTraceLimit: number;
201
- };
202
- declare const CStarConflictErrorImpl: {
203
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
204
- readonly type: string;
205
- readonly code: string;
206
- readonly param?: string;
207
- readonly docUrl: string;
208
- readonly requestId?: string;
209
- readonly statusCode: number;
210
- name: string;
211
- message: string;
212
- stack?: string;
213
- };
214
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
215
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
216
- stackTraceLimit: number;
217
- };
218
- declare const CStarServerErrorImpl: {
219
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
220
- readonly type: string;
221
- readonly code: string;
222
- readonly param?: string;
223
- readonly docUrl: string;
224
- readonly requestId?: string;
225
- readonly statusCode: number;
226
- name: string;
227
- message: string;
228
- stack?: string;
229
- };
230
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
231
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
232
- stackTraceLimit: number;
233
- };
234
- declare const CStarFeatureDisabledErrorImpl: {
235
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
236
- readonly feature: string;
237
- readonly enableUrl: string;
238
- readonly type: string;
239
- readonly code: string;
240
- readonly param?: string;
241
- readonly docUrl: string;
242
- readonly requestId?: string;
243
- readonly statusCode: number;
244
- name: string;
245
- message: string;
246
- stack?: string;
247
- };
248
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
249
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
250
- stackTraceLimit: number;
251
- };
252
- declare const CStarRealtimeUnavailableErrorImpl: {
253
- new (message?: string): {
254
- readonly type: string;
255
- readonly code: string;
256
- readonly param?: string;
257
- readonly docUrl: string;
258
- readonly requestId?: string;
259
- readonly statusCode: number;
260
- name: string;
261
- message: string;
262
- stack?: string;
263
- };
264
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
265
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
266
- stackTraceLimit: number;
267
- };
268
- declare const CStarError: {
269
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
270
- readonly type: string;
271
- readonly code: string;
272
- readonly param?: string;
273
- readonly docUrl: string;
274
- readonly requestId?: string;
275
- readonly statusCode: number;
276
- name: string;
277
- message: string;
278
- stack?: string;
279
- };
280
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
281
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
282
- stackTraceLimit: number;
283
- };
284
- type CStarError = InstanceType<typeof CStarErrorImpl>;
285
- declare const CStarAuthenticationError: {
286
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
287
- readonly type: string;
288
- readonly code: string;
289
- readonly param?: string;
290
- readonly docUrl: string;
291
- readonly requestId?: string;
292
- readonly statusCode: number;
293
- name: string;
294
- message: string;
295
- stack?: string;
296
- };
297
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
298
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
299
- stackTraceLimit: number;
300
- };
301
- type CStarAuthenticationError = InstanceType<typeof CStarAuthenticationErrorImpl>;
302
- declare const CStarRateLimitError: {
303
- new (messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number): {
304
- readonly retryAfter: number;
305
- readonly type: string;
306
- readonly code: string;
307
- readonly param?: string;
308
- readonly docUrl: string;
309
- readonly requestId?: string;
310
- readonly statusCode: number;
311
- name: string;
312
- message: string;
313
- stack?: string;
314
- };
315
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
316
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
317
- stackTraceLimit: number;
318
- };
319
- type CStarRateLimitError = InstanceType<typeof CStarRateLimitErrorImpl>;
320
- declare const CStarNotFoundError: {
321
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
322
- readonly type: string;
323
- readonly code: string;
324
- readonly param?: string;
325
- readonly docUrl: string;
326
- readonly requestId?: string;
327
- readonly statusCode: number;
328
- name: string;
329
- message: string;
330
- stack?: string;
331
- };
332
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
333
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
334
- stackTraceLimit: number;
335
- };
336
- type CStarNotFoundError = InstanceType<typeof CStarNotFoundErrorImpl>;
337
- declare const CStarValidationError: {
338
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
339
- readonly type: string;
340
- readonly code: string;
341
- readonly param?: string;
342
- readonly docUrl: string;
343
- readonly requestId?: string;
344
- readonly statusCode: number;
345
- name: string;
346
- message: string;
347
- stack?: string;
348
- };
349
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
350
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
351
- stackTraceLimit: number;
352
- };
353
- type CStarValidationError = InstanceType<typeof CStarValidationErrorImpl>;
354
- declare const CStarPermissionError: {
355
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
356
- readonly type: string;
357
- readonly code: string;
358
- readonly param?: string;
359
- readonly docUrl: string;
360
- readonly requestId?: string;
361
- readonly statusCode: number;
362
- name: string;
363
- message: string;
364
- stack?: string;
365
- };
366
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
367
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
368
- stackTraceLimit: number;
369
- };
370
- type CStarPermissionError = InstanceType<typeof CStarPermissionErrorImpl>;
371
- declare const CStarConflictError: {
372
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
373
- readonly type: string;
374
- readonly code: string;
375
- readonly param?: string;
376
- readonly docUrl: string;
377
- readonly requestId?: string;
378
- readonly statusCode: number;
379
- name: string;
380
- message: string;
381
- stack?: string;
382
- };
383
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
384
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
385
- stackTraceLimit: number;
386
- };
387
- type CStarConflictError = InstanceType<typeof CStarConflictErrorImpl>;
388
- declare const CStarServerError: {
389
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
390
- readonly type: string;
391
- readonly code: string;
392
- readonly param?: string;
393
- readonly docUrl: string;
394
- readonly requestId?: string;
395
- readonly statusCode: number;
396
- name: string;
397
- message: string;
398
- stack?: string;
399
- };
400
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
401
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
402
- stackTraceLimit: number;
403
- };
404
- type CStarServerError = InstanceType<typeof CStarServerErrorImpl>;
405
- declare const CStarFeatureDisabledError: {
406
- new (messageOrStatus: string | number, body?: ApiErrorBody): {
407
- readonly feature: string;
408
- readonly enableUrl: string;
409
- readonly type: string;
410
- readonly code: string;
411
- readonly param?: string;
412
- readonly docUrl: string;
413
- readonly requestId?: string;
414
- readonly statusCode: number;
415
- name: string;
416
- message: string;
417
- stack?: string;
418
- };
419
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
420
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
421
- stackTraceLimit: number;
422
- };
423
- type CStarFeatureDisabledError = InstanceType<typeof CStarFeatureDisabledErrorImpl>;
424
- declare const CStarRealtimeUnavailableError: {
425
- new (message?: string): {
426
- readonly type: string;
427
- readonly code: string;
428
- readonly param?: string;
429
- readonly docUrl: string;
430
- readonly requestId?: string;
431
- readonly statusCode: number;
432
- name: string;
433
- message: string;
434
- stack?: string;
435
- };
436
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
437
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
438
- stackTraceLimit: number;
439
- };
440
- type CStarRealtimeUnavailableError = InstanceType<typeof CStarRealtimeUnavailableErrorImpl>;
441
- /**
442
- * Parse a public-route response (anonymous LibraryClient, CommunityClient,
443
- * QuickHelpClient, AuthClient) into a typed `CStarError`.
444
- *
445
- * Public routes don't always emit the structured `{error: {type, code,
446
- * doc_url, ...}}` envelope — many emit `{error: 'message string'}` or
447
- * `{message: '...'}`. This helper normalizes both shapes and dispatches
448
- * on HTTP status (closes F-026 and F-034 — Library/Auth used to throw
449
- * plain `Error`).
450
- */
451
- declare function parsePublicError(status: number, body: unknown, fallbackMessage: string): CStarError;
452
- declare function parseError(statusCode: number, body: {
453
- error?: ApiErrorBody;
454
- } | null, retryAfter?: number): CStarError;
455
-
456
61
  /**
457
62
  * Customer authentication client for the cStar widget API.
458
63
  *
@@ -517,4 +122,4 @@ declare class AuthClient {
517
122
  private fetch;
518
123
  }
519
124
 
520
- export { type ApiErrorBody, AuthClient, type AuthConfig, type AuthCustomer, type AuthSession, CStarAuthenticationError, CStarConflictError, CStarError, CStarFeatureDisabledError, CStarNotFoundError, CStarPermissionError, CStarRateLimitError, CStarRealtimeUnavailableError, CStarServerError, CStarValidationError, ErrorType, type LoginParams, type LoginResult, type SignupConfirmationResult, type SignupParams, type SignupResult, parseError, parsePublicError };
125
+ export { AuthClient, type AuthConfig, type AuthCustomer, type AuthSession, type LoginParams, type LoginResult, type SignupConfirmationResult, type SignupParams, type SignupResult };