@broadcastingplatforms/sdk 0.0.0-dev.9cfcfc6
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/dist/auth-CRWthQ_B.d.mts +1176 -0
- package/dist/auth-CRWthQ_B.d.ts +1176 -0
- package/dist/auth.d.mts +1 -0
- package/dist/auth.d.ts +1 -0
- package/dist/auth.js +456 -0
- package/dist/auth.mjs +433 -0
- package/dist/base-client-BmVTsKhL.d.mts +70 -0
- package/dist/base-client-Dk56EJj-.d.ts +70 -0
- package/dist/browser-client.d.mts +47 -0
- package/dist/browser-client.d.ts +47 -0
- package/dist/browser-client.js +1983 -0
- package/dist/browser-client.mjs +1952 -0
- package/dist/channels.d.mts +1 -0
- package/dist/channels.d.ts +1 -0
- package/dist/channels.js +78 -0
- package/dist/channels.mjs +55 -0
- package/dist/chat.d.mts +1 -0
- package/dist/chat.d.ts +1 -0
- package/dist/chat.js +105 -0
- package/dist/chat.mjs +80 -0
- package/dist/errors.d.mts +68 -0
- package/dist/errors.d.ts +68 -0
- package/dist/errors.js +151 -0
- package/dist/errors.mjs +127 -0
- package/dist/http.d.mts +1 -0
- package/dist/http.d.ts +1 -0
- package/dist/http.js +323 -0
- package/dist/http.mjs +298 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2072 -0
- package/dist/index.mjs +2025 -0
- package/dist/realtime.d.mts +9 -0
- package/dist/realtime.d.ts +9 -0
- package/dist/realtime.js +1050 -0
- package/dist/realtime.mjs +1021 -0
- package/dist/resource.d.mts +1 -0
- package/dist/resource.d.ts +1 -0
- package/dist/resource.js +52 -0
- package/dist/resource.mjs +27 -0
- package/dist/server-client.d.mts +60 -0
- package/dist/server-client.d.ts +60 -0
- package/dist/server-client.js +1984 -0
- package/dist/server-client.mjs +1954 -0
- package/dist/storage.d.mts +149 -0
- package/dist/storage.d.ts +149 -0
- package/dist/storage.js +243 -0
- package/dist/storage.mjs +211 -0
- package/dist/streams.d.mts +1 -0
- package/dist/streams.d.ts +1 -0
- package/dist/streams.js +267 -0
- package/dist/streams.mjs +242 -0
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +19 -0
- package/dist/types.mjs +1 -0
- package/package.json +139 -0
|
@@ -0,0 +1,1176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base resource contract for typed endpoint clients.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Convert query parameters to a URL-encoded string.
|
|
7
|
+
*/
|
|
8
|
+
declare const buildQueryString: (params?: ResourceQueryParams) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Resource operations supported by SDK namespace clients.
|
|
11
|
+
*/
|
|
12
|
+
interface ResourceOperations {
|
|
13
|
+
/**
|
|
14
|
+
* List resource items.
|
|
15
|
+
* @param params - Query parameters for the list operation.
|
|
16
|
+
* @param options - HTTP request options.
|
|
17
|
+
* @returns List response payload.
|
|
18
|
+
*/
|
|
19
|
+
list(params?: ResourceQueryParams, options?: HttpRequestOptions): Promise<unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieve a resource item by id.
|
|
22
|
+
* @param id - Resource identifier.
|
|
23
|
+
* @param options - HTTP request options.
|
|
24
|
+
* @returns Get response payload.
|
|
25
|
+
*/
|
|
26
|
+
get(id: ResourceId, options?: HttpRequestOptions): Promise<unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new resource item.
|
|
29
|
+
* @param payload - Payload for the create operation.
|
|
30
|
+
* @param options - HTTP request options.
|
|
31
|
+
* @returns Create response payload.
|
|
32
|
+
*/
|
|
33
|
+
create(payload: unknown, options?: HttpRequestOptions): Promise<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Update an existing resource item.
|
|
36
|
+
* @param id - Resource identifier.
|
|
37
|
+
* @param payload - Payload for the update operation.
|
|
38
|
+
* @param options - HTTP request options.
|
|
39
|
+
* @returns Update response payload.
|
|
40
|
+
*/
|
|
41
|
+
update(id: ResourceId, payload: unknown, options?: HttpRequestOptions): Promise<unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Delete an existing resource item.
|
|
44
|
+
* @param id - Resource identifier.
|
|
45
|
+
* @param options - HTTP request options.
|
|
46
|
+
* @returns Delete response payload.
|
|
47
|
+
*/
|
|
48
|
+
delete(id: ResourceId, options?: HttpRequestOptions): Promise<unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* Create or update a resource item.
|
|
51
|
+
* @param id - Resource identifier.
|
|
52
|
+
* @param payload - Payload for the upsert operation.
|
|
53
|
+
* @param options - HTTP request options.
|
|
54
|
+
* @returns Upsert response payload.
|
|
55
|
+
*/
|
|
56
|
+
upsert(id: ResourceId, payload: unknown, options?: HttpRequestOptions): Promise<unknown>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Base resource contract implemented by namespace clients.
|
|
60
|
+
*/
|
|
61
|
+
interface BaseResource extends Partial<ResourceOperations> {
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Channels HTTP namespace for the SDK core package.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Channels namespace client backed by the shared HTTP client.
|
|
70
|
+
*/
|
|
71
|
+
declare class ChannelsClient implements BaseResource {
|
|
72
|
+
private readonly http;
|
|
73
|
+
/**
|
|
74
|
+
* Create a new channels client instance.
|
|
75
|
+
*/
|
|
76
|
+
constructor(http: HttpClient);
|
|
77
|
+
/**
|
|
78
|
+
* Fetch a channel by username.
|
|
79
|
+
*/
|
|
80
|
+
get(username: ResourceId, options?: HttpRequestOptions): Promise<ChannelResponse>;
|
|
81
|
+
/**
|
|
82
|
+
* Follow a channel by slug.
|
|
83
|
+
*/
|
|
84
|
+
follow(channelSlug: string, options?: HttpRequestOptions): Promise<ChannelResponse>;
|
|
85
|
+
/**
|
|
86
|
+
* Unfollow a channel by slug.
|
|
87
|
+
*/
|
|
88
|
+
unfollow(channelSlug: string, options?: HttpRequestOptions): Promise<ChannelResponse>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Chat HTTP namespace for the SDK core package.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Chat namespace client backed by the shared HTTP client.
|
|
97
|
+
*/
|
|
98
|
+
declare class ChatClient implements BaseResource {
|
|
99
|
+
private readonly http;
|
|
100
|
+
/**
|
|
101
|
+
* Create a new chat client instance.
|
|
102
|
+
*/
|
|
103
|
+
constructor(http: HttpClient);
|
|
104
|
+
/**
|
|
105
|
+
* Fetch chat history for a stream.
|
|
106
|
+
*/
|
|
107
|
+
getMessages(streamId: ResourceId, params?: ChatMessagesQuery, options?: HttpRequestOptions): Promise<ChatMessagesResponse>;
|
|
108
|
+
/**
|
|
109
|
+
* Resource-style alias for fetching chat messages by stream id.
|
|
110
|
+
* @param streamId - Stream identifier.
|
|
111
|
+
* @param options - Request options.
|
|
112
|
+
* @returns Chat messages response payload.
|
|
113
|
+
*/
|
|
114
|
+
get(streamId: ResourceId, options?: HttpRequestOptions): Promise<ChatMessagesResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Send a message to a stream chat.
|
|
117
|
+
*/
|
|
118
|
+
sendMessage(streamId: ResourceId, message: string, options?: HttpRequestOptions): Promise<ChatMessage>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Streams namespace client backed by the shared HTTP client.
|
|
123
|
+
*/
|
|
124
|
+
declare class StreamsClient implements BaseResource {
|
|
125
|
+
private readonly http;
|
|
126
|
+
/**
|
|
127
|
+
* Create a new streams client instance.
|
|
128
|
+
*/
|
|
129
|
+
constructor(http: HttpClient);
|
|
130
|
+
/**
|
|
131
|
+
* List active streams.
|
|
132
|
+
*/
|
|
133
|
+
listActive(options?: HttpRequestOptions): Promise<StreamListResponse>;
|
|
134
|
+
/**
|
|
135
|
+
* List streams with optional query params.
|
|
136
|
+
*/
|
|
137
|
+
list(params?: ResourceQueryParams, options?: HttpRequestOptions): Promise<StreamListResponse>;
|
|
138
|
+
/**
|
|
139
|
+
* Fetch a stream by id.
|
|
140
|
+
*/
|
|
141
|
+
get(streamId: ResourceId, options?: HttpRequestOptions): Promise<StreamResponse>;
|
|
142
|
+
/**
|
|
143
|
+
* Fetch a stream by channel slug.
|
|
144
|
+
* @param userLogin - Channel slug or login handle.
|
|
145
|
+
* @param options - Request options.
|
|
146
|
+
* @returns Stream payload when found, otherwise null.
|
|
147
|
+
*/
|
|
148
|
+
getBySlug(userLogin: string, options?: HttpRequestOptions): Promise<Stream | null>;
|
|
149
|
+
/**
|
|
150
|
+
* Fetch the player source payload for the given stream id.
|
|
151
|
+
*/
|
|
152
|
+
getPlayerSource(streamId: string | number, options?: HttpRequestOptions): Promise<StreamPlayerSource | null>;
|
|
153
|
+
/**
|
|
154
|
+
* Normalize stream payloads for get operations.
|
|
155
|
+
*/
|
|
156
|
+
private extractStreamPayload;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* SDK error codes derived from HTTP status codes and network failures.
|
|
161
|
+
*/
|
|
162
|
+
type SdkErrorCode = "authentication_required" | "permission_denied" | "not_found" | "validation_failed" | "rate_limited" | "server_error" | "unknown_error";
|
|
163
|
+
/**
|
|
164
|
+
* Structured error payload returned by the SDK.
|
|
165
|
+
*/
|
|
166
|
+
interface SdkErrorShape {
|
|
167
|
+
/**
|
|
168
|
+
* Canonical error code used by the SDK.
|
|
169
|
+
*/
|
|
170
|
+
code: SdkErrorCode;
|
|
171
|
+
/**
|
|
172
|
+
* HTTP status code when available.
|
|
173
|
+
*/
|
|
174
|
+
statusCode?: number;
|
|
175
|
+
/**
|
|
176
|
+
* Developer-facing error message.
|
|
177
|
+
*/
|
|
178
|
+
message: string;
|
|
179
|
+
/**
|
|
180
|
+
* End-user friendly error message.
|
|
181
|
+
*/
|
|
182
|
+
userMessage: string;
|
|
183
|
+
/**
|
|
184
|
+
* Request metadata (null when unavailable).
|
|
185
|
+
*/
|
|
186
|
+
request: Request | null;
|
|
187
|
+
/**
|
|
188
|
+
* Response metadata (null when unavailable).
|
|
189
|
+
*/
|
|
190
|
+
response: Response | null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* SDK error code alias matching SDKError naming.
|
|
194
|
+
*/
|
|
195
|
+
type SDKErrorCode = SdkErrorCode;
|
|
196
|
+
/**
|
|
197
|
+
* SDK error shape alias matching SDKError naming.
|
|
198
|
+
*/
|
|
199
|
+
type SDKErrorShape = SdkErrorShape;
|
|
200
|
+
/**
|
|
201
|
+
* Chat message user payload.
|
|
202
|
+
*/
|
|
203
|
+
interface ChatMessageUser {
|
|
204
|
+
/**
|
|
205
|
+
* User identifier.
|
|
206
|
+
*/
|
|
207
|
+
id: number;
|
|
208
|
+
/**
|
|
209
|
+
* User nickname.
|
|
210
|
+
*/
|
|
211
|
+
nick_name?: string;
|
|
212
|
+
/**
|
|
213
|
+
* User slug.
|
|
214
|
+
*/
|
|
215
|
+
slug?: string;
|
|
216
|
+
/**
|
|
217
|
+
* Whether the user is a model.
|
|
218
|
+
*/
|
|
219
|
+
is_model?: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Avatar URL.
|
|
222
|
+
*/
|
|
223
|
+
avatar_url?: string | null;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Chat message transaction payload.
|
|
227
|
+
*/
|
|
228
|
+
interface ChatMessageTransaction {
|
|
229
|
+
/**
|
|
230
|
+
* Transaction identifier.
|
|
231
|
+
*/
|
|
232
|
+
id: number;
|
|
233
|
+
/**
|
|
234
|
+
* Transaction amount.
|
|
235
|
+
*/
|
|
236
|
+
amount: number;
|
|
237
|
+
/**
|
|
238
|
+
* Transaction type.
|
|
239
|
+
*/
|
|
240
|
+
type: string;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Chat message metadata payload.
|
|
244
|
+
*/
|
|
245
|
+
interface ChatMessageMetadata {
|
|
246
|
+
/**
|
|
247
|
+
* Message duration.
|
|
248
|
+
*/
|
|
249
|
+
duration?: number;
|
|
250
|
+
/**
|
|
251
|
+
* Message intensity.
|
|
252
|
+
*/
|
|
253
|
+
intensity?: number;
|
|
254
|
+
/**
|
|
255
|
+
* Tip action payload.
|
|
256
|
+
*/
|
|
257
|
+
tip_action?: string;
|
|
258
|
+
/**
|
|
259
|
+
* Reply message reference.
|
|
260
|
+
*/
|
|
261
|
+
reply_to?: string;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Chat message payload.
|
|
265
|
+
*/
|
|
266
|
+
interface ChatMessage {
|
|
267
|
+
/**
|
|
268
|
+
* Message unique identifier.
|
|
269
|
+
*/
|
|
270
|
+
uuid?: string;
|
|
271
|
+
/**
|
|
272
|
+
* Message body.
|
|
273
|
+
*/
|
|
274
|
+
message?: string;
|
|
275
|
+
/**
|
|
276
|
+
* Message type.
|
|
277
|
+
*/
|
|
278
|
+
type?: string;
|
|
279
|
+
/**
|
|
280
|
+
* Timestamp offset for playback.
|
|
281
|
+
*/
|
|
282
|
+
timestamp_offset?: number;
|
|
283
|
+
/**
|
|
284
|
+
* Message creation timestamp.
|
|
285
|
+
*/
|
|
286
|
+
created_at?: string;
|
|
287
|
+
/**
|
|
288
|
+
* Message author payload.
|
|
289
|
+
*/
|
|
290
|
+
user?: ChatMessageUser;
|
|
291
|
+
/**
|
|
292
|
+
* Stream identifier.
|
|
293
|
+
*/
|
|
294
|
+
livestream_id?: number;
|
|
295
|
+
/**
|
|
296
|
+
* Chat room name.
|
|
297
|
+
*/
|
|
298
|
+
chat_room?: string;
|
|
299
|
+
/**
|
|
300
|
+
* Transaction payload when applicable.
|
|
301
|
+
*/
|
|
302
|
+
transaction?: ChatMessageTransaction;
|
|
303
|
+
/**
|
|
304
|
+
* Metadata payload when applicable.
|
|
305
|
+
*/
|
|
306
|
+
metadata?: ChatMessageMetadata;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Query parameters for chat message history.
|
|
310
|
+
*/
|
|
311
|
+
interface ChatMessagesQuery {
|
|
312
|
+
/**
|
|
313
|
+
* Timestamp for pagination.
|
|
314
|
+
*/
|
|
315
|
+
timestamp?: string;
|
|
316
|
+
/**
|
|
317
|
+
* Message limit.
|
|
318
|
+
*/
|
|
319
|
+
limit?: number;
|
|
320
|
+
/**
|
|
321
|
+
* Message status filters.
|
|
322
|
+
*/
|
|
323
|
+
status?: string[] | string;
|
|
324
|
+
/**
|
|
325
|
+
* Preserve additional query parameters.
|
|
326
|
+
*/
|
|
327
|
+
[key: string]: ResourceQueryValue | ResourceQueryValue[] | undefined;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Chat messages response payload.
|
|
331
|
+
*/
|
|
332
|
+
interface ChatMessagesResponse {
|
|
333
|
+
/**
|
|
334
|
+
* Chat messages payload.
|
|
335
|
+
*/
|
|
336
|
+
data?: ChatMessage[];
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Channel characteristic metadata.
|
|
340
|
+
*/
|
|
341
|
+
interface ChannelCharacteristics {
|
|
342
|
+
/**
|
|
343
|
+
* Age data when available.
|
|
344
|
+
*/
|
|
345
|
+
age?: string;
|
|
346
|
+
/**
|
|
347
|
+
* Height data when available.
|
|
348
|
+
*/
|
|
349
|
+
height?: string | null;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Tag metadata shared by channel and stream payloads.
|
|
353
|
+
*/
|
|
354
|
+
interface Tag {
|
|
355
|
+
/**
|
|
356
|
+
* Tag identifier.
|
|
357
|
+
*/
|
|
358
|
+
id: number;
|
|
359
|
+
/**
|
|
360
|
+
* Tag label.
|
|
361
|
+
*/
|
|
362
|
+
name: string;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Channel tag metadata.
|
|
366
|
+
*/
|
|
367
|
+
type ChannelTag = Tag;
|
|
368
|
+
/**
|
|
369
|
+
* Channel link metadata.
|
|
370
|
+
*/
|
|
371
|
+
interface ChannelLink {
|
|
372
|
+
/**
|
|
373
|
+
* Link identifier.
|
|
374
|
+
*/
|
|
375
|
+
id: number;
|
|
376
|
+
/**
|
|
377
|
+
* Provider name.
|
|
378
|
+
*/
|
|
379
|
+
provider: string | null;
|
|
380
|
+
/**
|
|
381
|
+
* Link URL.
|
|
382
|
+
*/
|
|
383
|
+
url: string;
|
|
384
|
+
/**
|
|
385
|
+
* Link update timestamp.
|
|
386
|
+
*/
|
|
387
|
+
last_updated: string;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Channel payload returned by the API.
|
|
391
|
+
*/
|
|
392
|
+
interface Channel {
|
|
393
|
+
/**
|
|
394
|
+
* Channel identifier.
|
|
395
|
+
*/
|
|
396
|
+
id: number;
|
|
397
|
+
/**
|
|
398
|
+
* Channel nickname.
|
|
399
|
+
*/
|
|
400
|
+
nick_name?: string;
|
|
401
|
+
/**
|
|
402
|
+
* Channel display name.
|
|
403
|
+
*/
|
|
404
|
+
display_name?: string;
|
|
405
|
+
/**
|
|
406
|
+
* Channel login handle.
|
|
407
|
+
*/
|
|
408
|
+
user_login?: string;
|
|
409
|
+
/**
|
|
410
|
+
* Channel slug.
|
|
411
|
+
*/
|
|
412
|
+
slug?: string;
|
|
413
|
+
/**
|
|
414
|
+
* Channel bio.
|
|
415
|
+
*/
|
|
416
|
+
bio?: string;
|
|
417
|
+
/**
|
|
418
|
+
* Channel avatar URL.
|
|
419
|
+
*/
|
|
420
|
+
avatar_url?: string | null;
|
|
421
|
+
/**
|
|
422
|
+
* Channel cover photo URL.
|
|
423
|
+
*/
|
|
424
|
+
cover_photo_url?: string | null;
|
|
425
|
+
/**
|
|
426
|
+
* Channel cover image.
|
|
427
|
+
*/
|
|
428
|
+
cover_image?: string | null;
|
|
429
|
+
/**
|
|
430
|
+
* Follower count.
|
|
431
|
+
*/
|
|
432
|
+
follower_count?: number;
|
|
433
|
+
/**
|
|
434
|
+
* Whether the current user is following this channel.
|
|
435
|
+
*/
|
|
436
|
+
is_following?: boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Whether the channel is active.
|
|
439
|
+
*/
|
|
440
|
+
is_active?: boolean;
|
|
441
|
+
/**
|
|
442
|
+
* Channel characteristics.
|
|
443
|
+
*/
|
|
444
|
+
characteristics?: ChannelCharacteristics;
|
|
445
|
+
/**
|
|
446
|
+
* Channel status.
|
|
447
|
+
*/
|
|
448
|
+
status?: string;
|
|
449
|
+
/**
|
|
450
|
+
* Channel timezone.
|
|
451
|
+
*/
|
|
452
|
+
timezone?: string;
|
|
453
|
+
/**
|
|
454
|
+
* Channel creation timestamp.
|
|
455
|
+
*/
|
|
456
|
+
created_at?: string;
|
|
457
|
+
/**
|
|
458
|
+
* Channel update timestamp.
|
|
459
|
+
*/
|
|
460
|
+
updated_at?: string;
|
|
461
|
+
/**
|
|
462
|
+
* Channel tags.
|
|
463
|
+
*/
|
|
464
|
+
tags?: ChannelTag[];
|
|
465
|
+
/**
|
|
466
|
+
* Channel links.
|
|
467
|
+
*/
|
|
468
|
+
links?: ChannelLink[];
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Channel response payload including active stream info.
|
|
472
|
+
*/
|
|
473
|
+
interface ChannelResponse {
|
|
474
|
+
/**
|
|
475
|
+
* Channel payload.
|
|
476
|
+
*/
|
|
477
|
+
channel?: Channel;
|
|
478
|
+
/**
|
|
479
|
+
* Active stream payload when available.
|
|
480
|
+
*/
|
|
481
|
+
active_stream?: Stream | null;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* HTTP request shape passed through interceptors.
|
|
485
|
+
*/
|
|
486
|
+
interface HttpRequest {
|
|
487
|
+
/**
|
|
488
|
+
* Fully resolved request URL.
|
|
489
|
+
*/
|
|
490
|
+
url: string;
|
|
491
|
+
/**
|
|
492
|
+
* Fetch options for the request.
|
|
493
|
+
*/
|
|
494
|
+
init: RequestInit;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Hook invoked before a request is sent.
|
|
498
|
+
*/
|
|
499
|
+
type BeforeRequestHook = (request: HttpRequest) => HttpRequest | void | Promise<HttpRequest | void>;
|
|
500
|
+
/**
|
|
501
|
+
* Fetch options for SDK HTTP requests.
|
|
502
|
+
*/
|
|
503
|
+
type HttpRequestOptions = RequestInit & {
|
|
504
|
+
/**
|
|
505
|
+
* Per-request headers to merge with defaults.
|
|
506
|
+
*/
|
|
507
|
+
headers?: Record<string, string>;
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* Realtime connection state values.
|
|
511
|
+
*/
|
|
512
|
+
type RealtimeConnectionState = "connecting" | "connected" | "unavailable" | "disconnected" | "failed";
|
|
513
|
+
/**
|
|
514
|
+
* Callback for realtime connection state changes.
|
|
515
|
+
*/
|
|
516
|
+
type RealtimeConnectionStateCallback = (state: RealtimeConnectionState) => void;
|
|
517
|
+
/**
|
|
518
|
+
* Realtime channel event callback.
|
|
519
|
+
*/
|
|
520
|
+
type RealtimeEventCallback<T = unknown> = (payload: T) => void;
|
|
521
|
+
/**
|
|
522
|
+
* Realtime channel wrapper interface.
|
|
523
|
+
*/
|
|
524
|
+
interface RealtimeChannel {
|
|
525
|
+
/**
|
|
526
|
+
* Listen for a realtime event.
|
|
527
|
+
*/
|
|
528
|
+
listen<T = unknown>(event: string, callback: RealtimeEventCallback<T>): void;
|
|
529
|
+
/**
|
|
530
|
+
* Stop listening for a realtime event.
|
|
531
|
+
*/
|
|
532
|
+
stopListening<T = unknown>(event?: string, callback?: RealtimeEventCallback<T>): void;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Realtime presence channel wrapper interface.
|
|
536
|
+
*/
|
|
537
|
+
interface RealtimePresenceChannel extends RealtimeChannel {
|
|
538
|
+
/**
|
|
539
|
+
* Get the current members in the channel.
|
|
540
|
+
* @returns Unsubscribe function for the presence callback.
|
|
541
|
+
*/
|
|
542
|
+
here(callback: (members: unknown[]) => void): () => void;
|
|
543
|
+
/**
|
|
544
|
+
* Listen for members joining the channel.
|
|
545
|
+
* @returns Unsubscribe function for the presence callback.
|
|
546
|
+
*/
|
|
547
|
+
joining(callback: (member: unknown) => void): () => void;
|
|
548
|
+
/**
|
|
549
|
+
* Listen for members leaving the channel.
|
|
550
|
+
* @returns Unsubscribe function for the presence callback.
|
|
551
|
+
*/
|
|
552
|
+
leaving(callback: (member: unknown) => void): () => void;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Options for configuring the realtime client.
|
|
556
|
+
*/
|
|
557
|
+
interface RealtimeClientOptions {
|
|
558
|
+
/**
|
|
559
|
+
* Base API URL used for auth endpoint resolution.
|
|
560
|
+
*/
|
|
561
|
+
baseUrl?: string;
|
|
562
|
+
/**
|
|
563
|
+
* Explicit auth endpoint override.
|
|
564
|
+
*/
|
|
565
|
+
authEndpoint?: string;
|
|
566
|
+
/**
|
|
567
|
+
* Pusher application key.
|
|
568
|
+
*/
|
|
569
|
+
appKey: string;
|
|
570
|
+
/**
|
|
571
|
+
* Websocket host for Pusher connections.
|
|
572
|
+
*/
|
|
573
|
+
wsHost: string;
|
|
574
|
+
/**
|
|
575
|
+
* Websocket port override.
|
|
576
|
+
*/
|
|
577
|
+
wsPort?: number;
|
|
578
|
+
/**
|
|
579
|
+
* Secure websocket port override.
|
|
580
|
+
*/
|
|
581
|
+
wssPort?: number;
|
|
582
|
+
/**
|
|
583
|
+
* Force TLS for websocket connections.
|
|
584
|
+
*/
|
|
585
|
+
forceTLS?: boolean;
|
|
586
|
+
/**
|
|
587
|
+
* Allowed websocket transports.
|
|
588
|
+
*/
|
|
589
|
+
enabledTransports?: string[];
|
|
590
|
+
/**
|
|
591
|
+
* Pusher cluster identifier.
|
|
592
|
+
*/
|
|
593
|
+
cluster?: string;
|
|
594
|
+
/**
|
|
595
|
+
* Provider function for resolving auth tokens.
|
|
596
|
+
*/
|
|
597
|
+
getToken?: () => Promise<string | null> | string | null;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Realtime options accepted by SDK client factories.
|
|
601
|
+
* Base URL and token provider are supplied by the SDK internally.
|
|
602
|
+
*/
|
|
603
|
+
type RealtimeClientOverrides = Omit<RealtimeClientOptions, "baseUrl" | "getToken">;
|
|
604
|
+
/**
|
|
605
|
+
* Realtime client interface.
|
|
606
|
+
*/
|
|
607
|
+
interface RealtimeClient {
|
|
608
|
+
/**
|
|
609
|
+
* Raw Pusher client instance for advanced usage.
|
|
610
|
+
*/
|
|
611
|
+
pusher: unknown | null;
|
|
612
|
+
/**
|
|
613
|
+
* Chat realtime helpers.
|
|
614
|
+
*/
|
|
615
|
+
chat: RealtimeChatClient;
|
|
616
|
+
/**
|
|
617
|
+
* Subscribe to a public channel.
|
|
618
|
+
*/
|
|
619
|
+
channel(name: string): RealtimeChannel;
|
|
620
|
+
/**
|
|
621
|
+
* Subscribe to a private channel.
|
|
622
|
+
*/
|
|
623
|
+
"private": (name: string) => RealtimeChannel;
|
|
624
|
+
/**
|
|
625
|
+
* Subscribe to a presence channel.
|
|
626
|
+
*/
|
|
627
|
+
join(name: string): RealtimePresenceChannel;
|
|
628
|
+
/**
|
|
629
|
+
* Leave a channel.
|
|
630
|
+
*/
|
|
631
|
+
leave(name: string): void;
|
|
632
|
+
/**
|
|
633
|
+
* Disconnect the realtime client.
|
|
634
|
+
*/
|
|
635
|
+
disconnect(): void;
|
|
636
|
+
/**
|
|
637
|
+
* Update the auth token for realtime subscriptions.
|
|
638
|
+
*/
|
|
639
|
+
setToken(token: string | null): void;
|
|
640
|
+
/**
|
|
641
|
+
* Listen for connection state changes.
|
|
642
|
+
*/
|
|
643
|
+
onConnectionStateChange(callback: RealtimeConnectionStateCallback): () => void;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Chat realtime helpers.
|
|
647
|
+
*/
|
|
648
|
+
interface RealtimeChatClient {
|
|
649
|
+
/**
|
|
650
|
+
* Join a chat room presence channel for the given channel id.
|
|
651
|
+
*/
|
|
652
|
+
joinRoom(channelId: ResourceId): RealtimePresenceChannel;
|
|
653
|
+
/**
|
|
654
|
+
* Leave a chat room presence channel for the given channel id.
|
|
655
|
+
*/
|
|
656
|
+
leaveRoom(channelId: ResourceId): void;
|
|
657
|
+
/**
|
|
658
|
+
* Listen for new chat messages.
|
|
659
|
+
*/
|
|
660
|
+
onMessage(channelId: ResourceId, callback: RealtimeEventCallback<ChatMessage>): () => void;
|
|
661
|
+
/**
|
|
662
|
+
* Listen for updated chat messages.
|
|
663
|
+
*/
|
|
664
|
+
onMessageUpdated(channelId: ResourceId, callback: RealtimeEventCallback<ChatMessage>): () => void;
|
|
665
|
+
/**
|
|
666
|
+
* Listen for deleted chat messages.
|
|
667
|
+
*/
|
|
668
|
+
onMessageDeleted(channelId: ResourceId, callback: RealtimeEventCallback<ChatMessage>): () => void;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Resource identifier type.
|
|
672
|
+
*/
|
|
673
|
+
type ResourceId = string | number;
|
|
674
|
+
/**
|
|
675
|
+
* Query parameter values for list operations.
|
|
676
|
+
*/
|
|
677
|
+
type ResourceQueryValue = string | number | boolean | null | undefined;
|
|
678
|
+
/**
|
|
679
|
+
* Query parameter map for list operations.
|
|
680
|
+
*/
|
|
681
|
+
type ResourceQueryParams = Record<string, ResourceQueryValue | ResourceQueryValue[]>;
|
|
682
|
+
/**
|
|
683
|
+
* SDK client wrapper exposing HTTP and auth helpers.
|
|
684
|
+
*/
|
|
685
|
+
interface SdkClient {
|
|
686
|
+
/**
|
|
687
|
+
* Auth client instance.
|
|
688
|
+
*/
|
|
689
|
+
auth: AuthClient;
|
|
690
|
+
/**
|
|
691
|
+
* HTTP client instance.
|
|
692
|
+
*/
|
|
693
|
+
http: HttpClient;
|
|
694
|
+
/**
|
|
695
|
+
* Realtime client instance.
|
|
696
|
+
*/
|
|
697
|
+
realtime: RealtimeClient;
|
|
698
|
+
/**
|
|
699
|
+
* Streams namespace client instance.
|
|
700
|
+
*/
|
|
701
|
+
streams: StreamsClient;
|
|
702
|
+
/**
|
|
703
|
+
* Channels namespace client instance.
|
|
704
|
+
*/
|
|
705
|
+
channels: ChannelsClient;
|
|
706
|
+
/**
|
|
707
|
+
* Chat namespace client instance.
|
|
708
|
+
*/
|
|
709
|
+
chat: ChatClient;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Storage adapter used for persisting auth tokens.
|
|
713
|
+
*/
|
|
714
|
+
interface StorageAdapter {
|
|
715
|
+
/**
|
|
716
|
+
* Read a value from storage.
|
|
717
|
+
*/
|
|
718
|
+
get(key: string): Promise<string | null> | string | null;
|
|
719
|
+
/**
|
|
720
|
+
* Persist a value into storage.
|
|
721
|
+
*/
|
|
722
|
+
set(key: string, value: string): Promise<void> | void;
|
|
723
|
+
/**
|
|
724
|
+
* Delete a value from storage.
|
|
725
|
+
*/
|
|
726
|
+
delete(key: string): Promise<void> | void;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Storage adapter with cookie prefix support.
|
|
730
|
+
*/
|
|
731
|
+
interface CookiesStorageAdapter extends StorageAdapter {
|
|
732
|
+
/**
|
|
733
|
+
* Prefix applied to cookie names for multi-app isolation.
|
|
734
|
+
*/
|
|
735
|
+
cookiePrefix: string;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Cookie options for browser-based storage adapters.
|
|
739
|
+
*/
|
|
740
|
+
interface CookieOptions {
|
|
741
|
+
/**
|
|
742
|
+
* Cookie path.
|
|
743
|
+
*/
|
|
744
|
+
path?: string;
|
|
745
|
+
/**
|
|
746
|
+
* Cookie domain.
|
|
747
|
+
*/
|
|
748
|
+
domain?: string;
|
|
749
|
+
/**
|
|
750
|
+
* Cookie expiry (Date or number of days).
|
|
751
|
+
*/
|
|
752
|
+
expires?: Date | number;
|
|
753
|
+
/**
|
|
754
|
+
* Secure cookie flag.
|
|
755
|
+
*/
|
|
756
|
+
secure?: boolean;
|
|
757
|
+
/**
|
|
758
|
+
* SameSite cookie policy.
|
|
759
|
+
*/
|
|
760
|
+
sameSite?: "lax" | "strict" | "none";
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Cookie accessors for server-side runtimes.
|
|
764
|
+
*/
|
|
765
|
+
interface CookieAccessors {
|
|
766
|
+
/**
|
|
767
|
+
* Get a cookie value by name.
|
|
768
|
+
*/
|
|
769
|
+
get(name: string): {
|
|
770
|
+
value: string;
|
|
771
|
+
} | string | null | undefined;
|
|
772
|
+
/**
|
|
773
|
+
* Set a cookie value by name.
|
|
774
|
+
*/
|
|
775
|
+
set(name: string, value: string, options?: CookieOptions): void;
|
|
776
|
+
/**
|
|
777
|
+
* Delete a cookie by name when supported.
|
|
778
|
+
*/
|
|
779
|
+
delete(name: string, options?: CookieOptions): void;
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Channel metadata associated with a stream.
|
|
783
|
+
*/
|
|
784
|
+
type StreamChannel = Pick<Channel, "id" | "nick_name" | "display_name" | "slug" | "bio" | "avatar_url" | "cover_photo_url" | "follower_count" | "status" | "timezone" | "created_at" | "updated_at">;
|
|
785
|
+
/**
|
|
786
|
+
* Stream tag metadata.
|
|
787
|
+
*/
|
|
788
|
+
type StreamTag = Tag;
|
|
789
|
+
/**
|
|
790
|
+
* Stream response payload.
|
|
791
|
+
*/
|
|
792
|
+
interface Stream {
|
|
793
|
+
/**
|
|
794
|
+
* Stream identifier.
|
|
795
|
+
*/
|
|
796
|
+
id: number;
|
|
797
|
+
/**
|
|
798
|
+
* Stream type (e.g. live, scheduled).
|
|
799
|
+
*/
|
|
800
|
+
type?: string;
|
|
801
|
+
/**
|
|
802
|
+
* Stream title.
|
|
803
|
+
*/
|
|
804
|
+
title?: string;
|
|
805
|
+
/**
|
|
806
|
+
* Stream description.
|
|
807
|
+
*/
|
|
808
|
+
description?: string | null;
|
|
809
|
+
/**
|
|
810
|
+
* Stream name identifier.
|
|
811
|
+
*/
|
|
812
|
+
stream_name?: string;
|
|
813
|
+
/**
|
|
814
|
+
* Stream start timestamp.
|
|
815
|
+
*/
|
|
816
|
+
started_at?: string | null;
|
|
817
|
+
/**
|
|
818
|
+
* Stream end timestamp.
|
|
819
|
+
*/
|
|
820
|
+
ended_at?: string | null;
|
|
821
|
+
/**
|
|
822
|
+
* Stream cover photo.
|
|
823
|
+
*/
|
|
824
|
+
cover_photo?: string | null;
|
|
825
|
+
/**
|
|
826
|
+
* Stream tags.
|
|
827
|
+
*/
|
|
828
|
+
tags?: StreamTag[];
|
|
829
|
+
/**
|
|
830
|
+
* Player source payload for stream playback.
|
|
831
|
+
*/
|
|
832
|
+
player_source?: StreamPlayerSource;
|
|
833
|
+
/**
|
|
834
|
+
* Associated channel payload.
|
|
835
|
+
*/
|
|
836
|
+
channel?: StreamChannel;
|
|
837
|
+
/**
|
|
838
|
+
* Current viewer count.
|
|
839
|
+
*/
|
|
840
|
+
viewer_count?: number;
|
|
841
|
+
/**
|
|
842
|
+
* Stream creation timestamp.
|
|
843
|
+
*/
|
|
844
|
+
created_at?: string;
|
|
845
|
+
/**
|
|
846
|
+
* Stream update timestamp.
|
|
847
|
+
*/
|
|
848
|
+
updated_at?: string;
|
|
849
|
+
/**
|
|
850
|
+
* Stream scheduled timestamp.
|
|
851
|
+
*/
|
|
852
|
+
scheduled_at?: string | null;
|
|
853
|
+
/**
|
|
854
|
+
* Expiry state flag.
|
|
855
|
+
*/
|
|
856
|
+
is_expired?: boolean;
|
|
857
|
+
/**
|
|
858
|
+
* Locked state flag.
|
|
859
|
+
*/
|
|
860
|
+
is_locked?: boolean;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Stream detail response payload.
|
|
864
|
+
*/
|
|
865
|
+
interface StreamResponse {
|
|
866
|
+
/**
|
|
867
|
+
* Stream payload.
|
|
868
|
+
*/
|
|
869
|
+
data?: Stream;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Stream list response wrapper.
|
|
873
|
+
*/
|
|
874
|
+
interface StreamListResponse {
|
|
875
|
+
/**
|
|
876
|
+
* Stream data array.
|
|
877
|
+
*/
|
|
878
|
+
data?: Stream[];
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Stream player source payload for the player runtime.
|
|
882
|
+
*/
|
|
883
|
+
interface StreamPlayerSource {
|
|
884
|
+
/**
|
|
885
|
+
* H5Live configuration payload.
|
|
886
|
+
*/
|
|
887
|
+
h5live?: {
|
|
888
|
+
/**
|
|
889
|
+
* Server endpoints.
|
|
890
|
+
*/
|
|
891
|
+
server?: {
|
|
892
|
+
websocket?: string;
|
|
893
|
+
hls?: string;
|
|
894
|
+
};
|
|
895
|
+
/**
|
|
896
|
+
* RTMP configuration.
|
|
897
|
+
*/
|
|
898
|
+
rtmp?: {
|
|
899
|
+
url?: string;
|
|
900
|
+
streamname?: string;
|
|
901
|
+
};
|
|
902
|
+
/**
|
|
903
|
+
* Security envelope.
|
|
904
|
+
*/
|
|
905
|
+
security?: {
|
|
906
|
+
expires?: string;
|
|
907
|
+
tag?: string;
|
|
908
|
+
token?: string;
|
|
909
|
+
options?: string;
|
|
910
|
+
};
|
|
911
|
+
};
|
|
912
|
+
/**
|
|
913
|
+
* Start index for player entries.
|
|
914
|
+
*/
|
|
915
|
+
startIndex?: number;
|
|
916
|
+
/**
|
|
917
|
+
* Player options.
|
|
918
|
+
*/
|
|
919
|
+
options?: {
|
|
920
|
+
switch?: {
|
|
921
|
+
method?: string;
|
|
922
|
+
pauseOnError?: boolean;
|
|
923
|
+
forcePlay?: boolean;
|
|
924
|
+
fastStart?: boolean;
|
|
925
|
+
timeout?: number;
|
|
926
|
+
incTiming?: boolean;
|
|
927
|
+
timestampReset?: boolean;
|
|
928
|
+
};
|
|
929
|
+
adaption?: {
|
|
930
|
+
rule?: string;
|
|
931
|
+
};
|
|
932
|
+
};
|
|
933
|
+
/**
|
|
934
|
+
* Available playback entries.
|
|
935
|
+
*/
|
|
936
|
+
entries?: Array<{
|
|
937
|
+
index?: number;
|
|
938
|
+
label?: string;
|
|
939
|
+
tag?: string;
|
|
940
|
+
info?: {
|
|
941
|
+
bitrate?: number;
|
|
942
|
+
width?: number;
|
|
943
|
+
height?: number;
|
|
944
|
+
framerate?: number;
|
|
945
|
+
};
|
|
946
|
+
h5live?: {
|
|
947
|
+
server?: {
|
|
948
|
+
websocket?: string;
|
|
949
|
+
hls?: string;
|
|
950
|
+
};
|
|
951
|
+
rtmp?: {
|
|
952
|
+
url?: string;
|
|
953
|
+
streamname?: string;
|
|
954
|
+
};
|
|
955
|
+
security?: {
|
|
956
|
+
expires?: string;
|
|
957
|
+
tag?: string;
|
|
958
|
+
token?: string;
|
|
959
|
+
options?: string;
|
|
960
|
+
};
|
|
961
|
+
};
|
|
962
|
+
}>;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Configuration for the SDK HTTP client.
|
|
967
|
+
*/
|
|
968
|
+
interface HttpClientOptions {
|
|
969
|
+
/**
|
|
970
|
+
* Base URL prepended to all requests.
|
|
971
|
+
*/
|
|
972
|
+
baseUrl: string;
|
|
973
|
+
/**
|
|
974
|
+
* Default headers applied to every request.
|
|
975
|
+
*/
|
|
976
|
+
headers?: Record<string, string>;
|
|
977
|
+
/**
|
|
978
|
+
* Fetch implementation (browser or polyfill).
|
|
979
|
+
*/
|
|
980
|
+
fetch?: typeof fetch;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* SDK HTTP client that supports interceptors and error mapping.
|
|
984
|
+
*/
|
|
985
|
+
declare class HttpClient {
|
|
986
|
+
private readonly baseUrl;
|
|
987
|
+
private readonly defaultHeaders;
|
|
988
|
+
private readonly fetcher;
|
|
989
|
+
private beforeRequestHooks;
|
|
990
|
+
/**
|
|
991
|
+
* Create a new HTTP client instance.
|
|
992
|
+
*/
|
|
993
|
+
constructor(options: HttpClientOptions);
|
|
994
|
+
/**
|
|
995
|
+
* Register a hook that runs before each request.
|
|
996
|
+
*/
|
|
997
|
+
onBeforeRequest(hook: BeforeRequestHook): () => void;
|
|
998
|
+
/**
|
|
999
|
+
* Execute an HTTP request and return the parsed response.
|
|
1000
|
+
*/
|
|
1001
|
+
request<T>(path: string, options?: HttpRequestOptions): Promise<T>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Execute an HTTP request and return the response with request metadata.
|
|
1004
|
+
*/
|
|
1005
|
+
requestWithMetadata<T>(path: string, options?: HttpRequestOptions): Promise<{
|
|
1006
|
+
data: T;
|
|
1007
|
+
request: Request;
|
|
1008
|
+
response: Response;
|
|
1009
|
+
}>;
|
|
1010
|
+
/**
|
|
1011
|
+
* Determine whether the provided URL is same-origin with the configured base URL.
|
|
1012
|
+
*/
|
|
1013
|
+
isSameOrigin(url: string): boolean;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* Supported auth state change events.
|
|
1018
|
+
*/
|
|
1019
|
+
type AuthStateChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED";
|
|
1020
|
+
/**
|
|
1021
|
+
* Login payload for username/password authentication.
|
|
1022
|
+
*/
|
|
1023
|
+
interface SignInPayload {
|
|
1024
|
+
/**
|
|
1025
|
+
* User email.
|
|
1026
|
+
*/
|
|
1027
|
+
email: string;
|
|
1028
|
+
/**
|
|
1029
|
+
* User password.
|
|
1030
|
+
*/
|
|
1031
|
+
password: string;
|
|
1032
|
+
/**
|
|
1033
|
+
* Optional login type (member/model).
|
|
1034
|
+
*/
|
|
1035
|
+
type?: string;
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Options for sign-in with a provided token.
|
|
1039
|
+
*/
|
|
1040
|
+
interface SignInWithTokenOptions {
|
|
1041
|
+
/**
|
|
1042
|
+
* If true, ensure the token is not expired before accepting it.
|
|
1043
|
+
*/
|
|
1044
|
+
verifySession?: boolean;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Options for the auth client.
|
|
1048
|
+
*/
|
|
1049
|
+
interface AuthClientOptions {
|
|
1050
|
+
/**
|
|
1051
|
+
* Storage adapter for persisting the token.
|
|
1052
|
+
* Provide an explicit adapter when using AuthClient directly.
|
|
1053
|
+
*/
|
|
1054
|
+
storage?: StorageAdapter;
|
|
1055
|
+
/**
|
|
1056
|
+
* Cookie accessors for server-side runtimes.
|
|
1057
|
+
*/
|
|
1058
|
+
cookies?: CookieAccessors;
|
|
1059
|
+
/**
|
|
1060
|
+
* Service key used as a bearer token when no user session is active.
|
|
1061
|
+
*/
|
|
1062
|
+
serviceKey?: string | null;
|
|
1063
|
+
/**
|
|
1064
|
+
* Storage key used for token persistence.
|
|
1065
|
+
*/
|
|
1066
|
+
storageKey?: string;
|
|
1067
|
+
/**
|
|
1068
|
+
* Prefix for the default cookie storage adapter.
|
|
1069
|
+
*/
|
|
1070
|
+
cookiePrefix?: string;
|
|
1071
|
+
/**
|
|
1072
|
+
* Cookie options for default cookie storage adapters.
|
|
1073
|
+
*/
|
|
1074
|
+
cookieOptions?: CookieOptions;
|
|
1075
|
+
/**
|
|
1076
|
+
* Enable automatic refresh flows (defaults to false).
|
|
1077
|
+
* Manual refresh via `refreshToken()` remains available regardless.
|
|
1078
|
+
*/
|
|
1079
|
+
autoRefresh?: boolean;
|
|
1080
|
+
/**
|
|
1081
|
+
* Seconds before expiry to refresh the token.
|
|
1082
|
+
*/
|
|
1083
|
+
refreshThresholdSeconds?: number;
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Listener for auth state changes.
|
|
1087
|
+
*/
|
|
1088
|
+
type AuthStateChangeCallback = (event: AuthStateChangeEvent, token: string | null) => void;
|
|
1089
|
+
/**
|
|
1090
|
+
* Auth client that manages token persistence and session lifecycle.
|
|
1091
|
+
*/
|
|
1092
|
+
declare class AuthClient {
|
|
1093
|
+
private readonly http;
|
|
1094
|
+
private readonly storage;
|
|
1095
|
+
private readonly storageKey;
|
|
1096
|
+
private readonly refreshEnabled;
|
|
1097
|
+
private readonly refreshThresholdSeconds;
|
|
1098
|
+
private readonly serviceKey;
|
|
1099
|
+
private currentSession;
|
|
1100
|
+
private readonly stateListeners;
|
|
1101
|
+
private restorePromise;
|
|
1102
|
+
/**
|
|
1103
|
+
* Track whether storage restoration has already been attempted.
|
|
1104
|
+
*/
|
|
1105
|
+
private restoreAttempted;
|
|
1106
|
+
/**
|
|
1107
|
+
* Create a new auth client instance.
|
|
1108
|
+
*/
|
|
1109
|
+
constructor(http: HttpClient, options?: AuthClientOptions);
|
|
1110
|
+
/**
|
|
1111
|
+
* Set the current bearer token, or clear it when null.
|
|
1112
|
+
*/
|
|
1113
|
+
setToken(token: string | null): Promise<string | null>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Get the currently configured token (if any).
|
|
1116
|
+
*/
|
|
1117
|
+
getToken(): string | null;
|
|
1118
|
+
/**
|
|
1119
|
+
* Clear the current token and session.
|
|
1120
|
+
*/
|
|
1121
|
+
clearToken(): Promise<void>;
|
|
1122
|
+
/**
|
|
1123
|
+
* Sign in using a JWT token.
|
|
1124
|
+
*/
|
|
1125
|
+
signInWithToken(token: string, options?: SignInWithTokenOptions): Promise<string>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Sign in using email/password credentials.
|
|
1128
|
+
*/
|
|
1129
|
+
signIn(payload: SignInPayload): Promise<string>;
|
|
1130
|
+
/**
|
|
1131
|
+
* Sign out the current user.
|
|
1132
|
+
*/
|
|
1133
|
+
signOut(): Promise<void>;
|
|
1134
|
+
/**
|
|
1135
|
+
* Get the current session, restoring from storage if needed.
|
|
1136
|
+
*/
|
|
1137
|
+
getSession(): Promise<string | null>;
|
|
1138
|
+
/**
|
|
1139
|
+
* Refresh the current session token.
|
|
1140
|
+
* Manual refresh is always available; automatic refresh is controlled
|
|
1141
|
+
* by the `autoRefresh` option.
|
|
1142
|
+
*/
|
|
1143
|
+
refreshToken(): Promise<string>;
|
|
1144
|
+
/**
|
|
1145
|
+
* Subscribe to auth state changes.
|
|
1146
|
+
*/
|
|
1147
|
+
onAuthStateChange(callback: AuthStateChangeCallback): () => void;
|
|
1148
|
+
private emitState;
|
|
1149
|
+
/**
|
|
1150
|
+
* Register the auth header hook for outgoing HTTP requests.
|
|
1151
|
+
*/
|
|
1152
|
+
private registerAuthHook;
|
|
1153
|
+
/**
|
|
1154
|
+
* Resolve the bearer token to use for outgoing requests.
|
|
1155
|
+
*/
|
|
1156
|
+
private resolveRequestToken;
|
|
1157
|
+
/**
|
|
1158
|
+
* Persist a token update and notify listeners.
|
|
1159
|
+
*/
|
|
1160
|
+
private applyToken;
|
|
1161
|
+
/**
|
|
1162
|
+
* Restore a persisted token from storage when needed.
|
|
1163
|
+
*/
|
|
1164
|
+
private restoreFromStorage;
|
|
1165
|
+
/**
|
|
1166
|
+
* Determine if the client is currently using the service key.
|
|
1167
|
+
*/
|
|
1168
|
+
private isUsingServiceKey;
|
|
1169
|
+
/**
|
|
1170
|
+
* Resolve the auth token from a response payload and request metadata.
|
|
1171
|
+
*/
|
|
1172
|
+
private resolveTokenFromResponse;
|
|
1173
|
+
private assertTokenNotExpired;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
export { buildQueryString as $, AuthClient as A, type BaseResource as B, ChannelsClient as C, type ResourceId as D, type ResourceQueryParams as E, type ResourceQueryValue as F, type Stream as G, type HttpClientOptions as H, type StreamChannel as I, type StreamListResponse as J, type StreamPlayerSource as K, type StreamResponse as L, type StreamTag as M, type Channel as N, type ChannelCharacteristics as O, type ChannelLink as P, type ChannelResponse as Q, type RealtimeChannel as R, StreamsClient as S, type ChannelTag as T, type ChatMessage as U, type ChatMessageMetadata as V, type ChatMessagesQuery as W, type ChatMessagesResponse as X, type ChatMessageTransaction as Y, type ChatMessageUser as Z, type RealtimeClientOverrides as _, HttpClient as a, type Tag as a0, type AuthClientOptions as b, type AuthStateChangeCallback as c, type AuthStateChangeEvent as d, type SignInPayload as e, type SignInWithTokenOptions as f, ChatClient as g, type SdkClient as h, type BeforeRequestHook as i, type CookieAccessors as j, type CookieOptions as k, type CookiesStorageAdapter as l, type HttpRequest as m, type HttpRequestOptions as n, type RealtimeChatClient as o, type RealtimeClient as p, type RealtimeClientOptions as q, type RealtimeConnectionState as r, type RealtimeConnectionStateCallback as s, type RealtimeEventCallback as t, type RealtimePresenceChannel as u, type SDKErrorCode as v, type SdkErrorCode as w, type SDKErrorShape as x, type SdkErrorShape as y, type StorageAdapter as z };
|