@cstar.help/js 0.14.0 → 0.15.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.
@@ -20,7 +20,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/auth/index.ts
21
21
  var auth_exports = {};
22
22
  __export(auth_exports, {
23
- AuthClient: () => AuthClient
23
+ AuthClient: () => AuthClient,
24
+ CStarAuthenticationError: () => CStarAuthenticationError,
25
+ CStarConflictError: () => CStarConflictError,
26
+ CStarError: () => CStarError,
27
+ CStarFeatureDisabledError: () => CStarFeatureDisabledError,
28
+ CStarNotFoundError: () => CStarNotFoundError,
29
+ CStarPermissionError: () => CStarPermissionError,
30
+ CStarRateLimitError: () => CStarRateLimitError,
31
+ CStarRealtimeUnavailableError: () => CStarRealtimeUnavailableError,
32
+ CStarServerError: () => CStarServerError,
33
+ CStarValidationError: () => CStarValidationError,
34
+ ErrorType: () => ErrorType,
35
+ parseError: () => parseError,
36
+ parsePublicError: () => parsePublicError
24
37
  });
25
38
  module.exports = __toCommonJS(auth_exports);
26
39
 
@@ -61,7 +74,7 @@ function normalizeArgs(messageOrStatus, maybeBody, defaults) {
61
74
  }
62
75
  };
63
76
  }
64
- var CStarError = class extends Error {
77
+ var CStarErrorImpl = class extends Error {
65
78
  constructor(messageOrStatus, body) {
66
79
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body);
67
80
  super(resolved.message);
@@ -74,7 +87,7 @@ var CStarError = class extends Error {
74
87
  this.statusCode = statusCode;
75
88
  }
76
89
  };
77
- var CStarAuthenticationError = class extends CStarError {
90
+ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
78
91
  constructor(messageOrStatus, body) {
79
92
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
80
93
  type: ErrorType.AUTHENTICATION_ERROR,
@@ -85,7 +98,7 @@ var CStarAuthenticationError = class extends CStarError {
85
98
  this.name = "CStarAuthenticationError";
86
99
  }
87
100
  };
88
- var CStarRateLimitError = class extends CStarError {
101
+ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
89
102
  constructor(messageOrStatus, body, retryAfter) {
90
103
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
91
104
  type: ErrorType.RATE_LIMIT_ERROR,
@@ -97,7 +110,7 @@ var CStarRateLimitError = class extends CStarError {
97
110
  this.retryAfter = retryAfter ?? 60;
98
111
  }
99
112
  };
100
- var CStarNotFoundError = class extends CStarError {
113
+ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
101
114
  constructor(messageOrStatus, body) {
102
115
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
103
116
  type: ErrorType.NOT_FOUND_ERROR,
@@ -108,7 +121,7 @@ var CStarNotFoundError = class extends CStarError {
108
121
  this.name = "CStarNotFoundError";
109
122
  }
110
123
  };
111
- var CStarValidationError = class extends CStarError {
124
+ var CStarValidationErrorImpl = class extends CStarErrorImpl {
112
125
  constructor(messageOrStatus, body) {
113
126
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
114
127
  type: ErrorType.INVALID_REQUEST_ERROR,
@@ -119,7 +132,7 @@ var CStarValidationError = class extends CStarError {
119
132
  this.name = "CStarValidationError";
120
133
  }
121
134
  };
122
- var CStarPermissionError = class extends CStarError {
135
+ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
123
136
  constructor(messageOrStatus, body) {
124
137
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
125
138
  type: ErrorType.PERMISSION_ERROR,
@@ -130,7 +143,7 @@ var CStarPermissionError = class extends CStarError {
130
143
  this.name = "CStarPermissionError";
131
144
  }
132
145
  };
133
- var CStarConflictError = class extends CStarError {
146
+ var CStarConflictErrorImpl = class extends CStarErrorImpl {
134
147
  constructor(messageOrStatus, body) {
135
148
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
136
149
  type: ErrorType.CONFLICT_ERROR,
@@ -141,7 +154,7 @@ var CStarConflictError = class extends CStarError {
141
154
  this.name = "CStarConflictError";
142
155
  }
143
156
  };
144
- var CStarServerError = class extends CStarError {
157
+ var CStarServerErrorImpl = class extends CStarErrorImpl {
145
158
  constructor(messageOrStatus, body) {
146
159
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
147
160
  type: ErrorType.SERVER_ERROR,
@@ -152,7 +165,7 @@ var CStarServerError = class extends CStarError {
152
165
  this.name = "CStarServerError";
153
166
  }
154
167
  };
155
- var CStarFeatureDisabledError = class extends CStarError {
168
+ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
156
169
  constructor(messageOrStatus, body) {
157
170
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
158
171
  type: ErrorType.FEATURE_NOT_CONFIGURED,
@@ -165,6 +178,62 @@ var CStarFeatureDisabledError = class extends CStarError {
165
178
  this.enableUrl = resolved.enable_url ?? "";
166
179
  }
167
180
  };
181
+ var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
182
+ constructor(message) {
183
+ const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://cstar.help/developers/sdk/realtime#ssr";
184
+ super(0, {
185
+ type: ErrorType.API_ERROR,
186
+ code: "realtime_unavailable",
187
+ message: resolved,
188
+ doc_url: "https://cstar.help/developers/sdk/realtime#ssr"
189
+ });
190
+ this.name = "CStarRealtimeUnavailableError";
191
+ }
192
+ };
193
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@cstar.help/js/errors/v1");
194
+ var globalSlot = globalThis;
195
+ var registry = globalSlot[REGISTRY_KEY] ?? (globalSlot[REGISTRY_KEY] = {
196
+ CStarError: CStarErrorImpl,
197
+ CStarAuthenticationError: CStarAuthenticationErrorImpl,
198
+ CStarRateLimitError: CStarRateLimitErrorImpl,
199
+ CStarNotFoundError: CStarNotFoundErrorImpl,
200
+ CStarValidationError: CStarValidationErrorImpl,
201
+ CStarPermissionError: CStarPermissionErrorImpl,
202
+ CStarConflictError: CStarConflictErrorImpl,
203
+ CStarServerError: CStarServerErrorImpl,
204
+ CStarFeatureDisabledError: CStarFeatureDisabledErrorImpl,
205
+ CStarRealtimeUnavailableError: CStarRealtimeUnavailableErrorImpl
206
+ });
207
+ var NAME_FIXES = [
208
+ "CStarError",
209
+ "CStarAuthenticationError",
210
+ "CStarRateLimitError",
211
+ "CStarNotFoundError",
212
+ "CStarValidationError",
213
+ "CStarPermissionError",
214
+ "CStarConflictError",
215
+ "CStarServerError",
216
+ "CStarFeatureDisabledError",
217
+ "CStarRealtimeUnavailableError"
218
+ ];
219
+ for (const key of NAME_FIXES) {
220
+ if (registry[key].name !== key) {
221
+ Object.defineProperty(registry[key], "name", {
222
+ value: key,
223
+ configurable: true
224
+ });
225
+ }
226
+ }
227
+ var CStarError = registry.CStarError;
228
+ var CStarAuthenticationError = registry.CStarAuthenticationError;
229
+ var CStarRateLimitError = registry.CStarRateLimitError;
230
+ var CStarNotFoundError = registry.CStarNotFoundError;
231
+ var CStarValidationError = registry.CStarValidationError;
232
+ var CStarPermissionError = registry.CStarPermissionError;
233
+ var CStarConflictError = registry.CStarConflictError;
234
+ var CStarServerError = registry.CStarServerError;
235
+ var CStarFeatureDisabledError = registry.CStarFeatureDisabledError;
236
+ var CStarRealtimeUnavailableError = registry.CStarRealtimeUnavailableError;
168
237
  function parsePublicError(status, body, fallbackMessage) {
169
238
  const obj = body && typeof body === "object" ? body : null;
170
239
  const errVal = obj?.error;
@@ -337,5 +406,18 @@ var AuthClient = class {
337
406
  };
338
407
  // Annotate the CommonJS export names for ESM import in node:
339
408
  0 && (module.exports = {
340
- AuthClient
409
+ AuthClient,
410
+ CStarAuthenticationError,
411
+ CStarConflictError,
412
+ CStarError,
413
+ CStarFeatureDisabledError,
414
+ CStarNotFoundError,
415
+ CStarPermissionError,
416
+ CStarRateLimitError,
417
+ CStarRealtimeUnavailableError,
418
+ CStarServerError,
419
+ CStarValidationError,
420
+ ErrorType,
421
+ parseError,
422
+ parsePublicError
341
423
  });
@@ -56,6 +56,403 @@ interface AuthSession {
56
56
  refreshToken: string;
57
57
  }
58
58
 
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
+
59
456
  /**
60
457
  * Customer authentication client for the cStar widget API.
61
458
  *
@@ -120,4 +517,4 @@ declare class AuthClient {
120
517
  private fetch;
121
518
  }
122
519
 
123
- export { AuthClient, type AuthConfig, type AuthCustomer, type AuthSession, type LoginParams, type LoginResult, type SignupConfirmationResult, type SignupParams, type SignupResult };
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 };