cime-sdk 1.0.0

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.
@@ -0,0 +1,806 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { EventEmitter } from 'events';
3
+
4
+ /**
5
+ * ci.me API에서 사용되는 권한(Scope) 목록입니다.
6
+ */
7
+ type CimeScope = 'READ:USER' | 'READ:CHANNEL' | 'READ:LIVE_CHAT' | 'WRITE:LIVE_CHAT' | 'READ:DONATION' | 'WRITE:USER_BLOCK' | 'READ:USER_BLOCK' | 'READ:LIVE_STREAM_KEY' | 'READ:SUBSCRIPTION' | 'READ:LIVE_STREAM_SETTINGS' | 'WRITE:LIVE_STREAM_SETTINGS' | 'READ:LIVE_CHAT_SETTINGS' | 'WRITE:LIVE_CHAT_SETTINGS' | 'WRITE:LIVE_CHAT_NOTICE';
8
+ /**
9
+ * 토큰 발급/갱신 요청 인터페이스
10
+ */
11
+ interface CimeTokenRequest {
12
+ grantType: 'authorization_code' | 'refresh_token';
13
+ clientId: string;
14
+ clientSecret: string;
15
+ code?: string;
16
+ refreshToken?: string;
17
+ }
18
+ /**
19
+ * 토큰 발급/갱신 응답 인터페이스
20
+ */
21
+ interface CimeTokenResponse {
22
+ accessToken: string;
23
+ refreshToken: string;
24
+ expiresIn: number;
25
+ tokenType: string;
26
+ scope: string;
27
+ }
28
+ /**
29
+ * 토큰 취소 요청 인터페이스
30
+ */
31
+ interface CimeRevokeTokenRequest {
32
+ clientId: string;
33
+ clientSecret: string;
34
+ token: string;
35
+ tokenTypeHint: 'access_token' | 'refresh_token';
36
+ }
37
+
38
+ /**
39
+ * 내 정보(채널) 조회 API의 응답 객체 인터페이스입니다.
40
+ */
41
+ interface CimeUser {
42
+ channelId: string;
43
+ channelName: string;
44
+ channelHandle: string;
45
+ channelImageUrl: string;
46
+ }
47
+
48
+ /**
49
+ * 배열 형태의 데이터를 반환하는 API의 공통 content 인터페이스입니다.
50
+ * API 응답이 `{ content: { data: [...] } }` 형태일 때 사용합니다.
51
+ */
52
+ interface CimeDataList<T> {
53
+ data: T[];
54
+ }
55
+ /**
56
+ * 채널 기본 정보
57
+ */
58
+ interface CimeChannelInfo {
59
+ channelId: string;
60
+ channelName: string;
61
+ channelHandle: string;
62
+ channelImageUrl: string | null;
63
+ channelDescription: string;
64
+ followerCount: number;
65
+ }
66
+ /**
67
+ * 팔로워 정보
68
+ */
69
+ interface CimeFollower {
70
+ channelId: string;
71
+ channelName: string;
72
+ channelHandle: string;
73
+ /** 팔로우 시작 시간 (ISO 8601) */
74
+ createdDate: string;
75
+ }
76
+ /**
77
+ * 팔로워 목록 조회 파라미터
78
+ */
79
+ interface CimeChannelFollowersParams {
80
+ /** 페이지 번호 (0부터 시작, 기본값: 0) */
81
+ page?: number;
82
+ /** 페이지 크기 (기본값: 20) */
83
+ size?: number;
84
+ }
85
+ /**
86
+ * 구독자 정보
87
+ */
88
+ interface CimeSubscriber {
89
+ channelId: string;
90
+ channelName: string;
91
+ channelHandle: string;
92
+ /** 연속 구독 개월 수 */
93
+ month: number;
94
+ /** 구독 티어 번호 */
95
+ tierNo: number;
96
+ /** 구독 시작 시간 (ISO 8601) */
97
+ createdDate: string;
98
+ }
99
+ /**
100
+ * 구독자 목록 조회 파라미터
101
+ */
102
+ interface CimeChannelSubscribersParams {
103
+ /** 페이지 번호 (0부터 시작, 기본값: 0) */
104
+ page?: number;
105
+ /** 페이지 크기 (1~50, 기본값: 30) */
106
+ size?: number;
107
+ /** 정렬 기준 (기본값: 'RECENT') */
108
+ sort?: 'RECENT' | 'LONGER';
109
+ }
110
+ /**
111
+ * 채널 관리자 역할 종류
112
+ */
113
+ type CimeStreamingRole = 'STREAMING_CHANNEL_OWNER' | 'STREAMING_CHANNEL_MANAGER' | 'STREAMING_CHAT_MANAGER' | 'STREAMING_SETTLEMENT_MANAGER';
114
+ /**
115
+ * 채널 관리자 정보
116
+ */
117
+ interface CimeManager {
118
+ managerChannelId: string;
119
+ managerChannelName: string;
120
+ managerChannelHandle: string;
121
+ userRole: CimeStreamingRole;
122
+ /** 역할 부여 일시 (ISO 8601) */
123
+ createdDate: string;
124
+ }
125
+
126
+ /**
127
+ * 커서 기반 페이지네이션 응답의 페이지 정보
128
+ */
129
+ interface CimeCursorPage {
130
+ next: string | null;
131
+ }
132
+ /**
133
+ * 커서 기반 페이지네이션을 사용하는 API의 공통 content 인터페이스입니다.
134
+ */
135
+ interface CimeCursorList<T> {
136
+ data: T[];
137
+ page: CimeCursorPage;
138
+ }
139
+ /**
140
+ * 라이브 방송 기본 정보
141
+ */
142
+ interface CimeLive {
143
+ liveId: string;
144
+ liveTitle: string;
145
+ liveThumbnailImageUrl: string | null;
146
+ concurrentUserCount: number;
147
+ /** 라이브 시작 시간 (ISO 8601) */
148
+ openedDate: string | null;
149
+ /** 연령 제한 설정 여부 */
150
+ adult: boolean;
151
+ tags: string[];
152
+ categoryType: string | null;
153
+ liveCategory: string | null;
154
+ liveCategoryValue: string | null;
155
+ channelId: string;
156
+ channelName: string;
157
+ channelHandle: string;
158
+ channelImageUrl: string | null;
159
+ }
160
+ /**
161
+ * 라이브 목록 조회 파라미터
162
+ */
163
+ interface CimeLivesParams {
164
+ /** 페이지 크기 (1~20, 기본값: 20) */
165
+ size?: number;
166
+ /** 다음 페이지 커서 값 */
167
+ next?: string;
168
+ }
169
+ /**
170
+ * 라이브 설정 정보
171
+ */
172
+ interface CimeLiveSetting {
173
+ defaultLiveTitle: string;
174
+ category: Record<string, any> | null;
175
+ tags: string[];
176
+ }
177
+ /**
178
+ * 라이브 설정 변경 파라미터
179
+ * 모든 필드는 선택 사항이며, 전달된 필드만 업데이트됩니다.
180
+ */
181
+ interface CimeUpdateLiveSettingParams {
182
+ /** 라이브 제목 (1~100자) */
183
+ defaultLiveTitle?: string;
184
+ /** 태그 목록 (최대 6개) */
185
+ tags?: string[];
186
+ /** 카테고리 ID. null로 설정 시 카테고리 제거 */
187
+ categoryId?: string | null;
188
+ }
189
+ /**
190
+ * 스트림 키 정보
191
+ */
192
+ interface CimeStreamKey {
193
+ streamKey: string;
194
+ }
195
+ /**
196
+ * 라이브 방송 상태 정보
197
+ */
198
+ interface CimeLiveStatus {
199
+ isLive: boolean;
200
+ title: string | null;
201
+ openedAt: string | null;
202
+ }
203
+
204
+ /**
205
+ * 채팅 허용 그룹 (모두, 팔로워 전용, 관리자 전용)
206
+ */
207
+ type CimeChatAllowedGroup = 'ALL' | 'FOLLOWER' | 'MANAGER';
208
+ /**
209
+ * 채팅 설정 정보
210
+ */
211
+ interface CimeChatSettings {
212
+ chatAllowedGroup: CimeChatAllowedGroup;
213
+ /** 최소 팔로우 시간 (분). FOLLOWER 모드일 때 적용됩니다. */
214
+ minFollowerMinute: number;
215
+ /** 팔로워 모드에서 구독자 즉시 채팅 허용 여부 */
216
+ followerSubscriberChatAllow: boolean | null;
217
+ }
218
+ /**
219
+ * 채팅 설정 변경 파라미터
220
+ * 모든 필드는 선택사항이며, 전달된 필드만 업데이트됩니다.
221
+ */
222
+ interface CimeUpdateChatSettingsParams {
223
+ /** 이모지 전용 모드 여부 */
224
+ chatEmojiMode?: boolean;
225
+ /** 채팅 딜레이 (초) */
226
+ chatSlowModeSec?: number;
227
+ chatAllowedGroup?: CimeChatAllowedGroup;
228
+ /** 최소 팔로우 시간 (분) */
229
+ minFollowerMinute?: number;
230
+ /** 팔로워 모드에서 구독자 즉시 채팅 허용 여부 */
231
+ followerSubscriberChatAllow?: boolean;
232
+ }
233
+ /**
234
+ * 채팅 메시지 전송 파라미터
235
+ */
236
+ interface CimeSendChatMessageParams {
237
+ /** 전송할 메시지 (1~100자) */
238
+ message: string;
239
+ /** * 발신자 타입 (기본값: APP)
240
+ * - APP: 애플리케이션 소유자 이름으로 표시
241
+ * - USER: 인증된 사용자 본인 이름으로 표시
242
+ */
243
+ senderType?: 'APP' | 'USER';
244
+ }
245
+ /**
246
+ * 채팅 메시지 전송 응답
247
+ */
248
+ interface CimeSendChatMessageResponse {
249
+ messageId: string;
250
+ }
251
+ /**
252
+ * 채팅 공지 등록 파라미터
253
+ * 주의: message 또는 messageId 중 하나는 반드시 제공되어야 합니다.
254
+ */
255
+ interface CimeRegisterChatNoticeParams {
256
+ /** 새 메시지로 공지 등록 시 사용 (1~100자) */
257
+ message?: string;
258
+ /** 기존 메시지를 공지로 등록 시 사용 */
259
+ messageId?: string;
260
+ }
261
+ /**
262
+ * 실시간 채팅 이벤트의 프로필 정보
263
+ */
264
+ interface CimeChatProfile {
265
+ nickname: string;
266
+ }
267
+ /**
268
+ * 실시간 CHAT 이벤트 수신 시 전달되는 데이터 페이로드
269
+ */
270
+ interface CimeChatEventData {
271
+ /** 채팅이 발생한 채널의 ID */
272
+ channelId: string;
273
+ /** 메시지 작성자의 채널 ID */
274
+ senderChannelId: string;
275
+ /** 작성자 프로필 정보 */
276
+ profile: CimeChatProfile;
277
+ /** 채팅 메시지 원본 (이모티콘 토큰 포함 가능) */
278
+ content: string;
279
+ /** 메시지 전송 시간 (ISO 8601) */
280
+ messageTime: string;
281
+ /** 이모티콘 토큰 -> 이미지 URL 매핑 객체 */
282
+ emojis: Record<string, string>;
283
+ }
284
+
285
+ /**
286
+ * 카테고리 정보
287
+ */
288
+ interface CimeCategory {
289
+ categoryId: string;
290
+ categoryType: string;
291
+ categoryValue: string;
292
+ posterImageUrl: string | null;
293
+ }
294
+ /**
295
+ * 카테고리 검색 파라미터
296
+ */
297
+ interface CimeSearchCategoriesParams {
298
+ /** 검색 키워드. 미입력 시 전체 카테고리를 반환합니다. */
299
+ keyword?: string;
300
+ /** 검색 결과 수 (1~50, 기본값: 20) */
301
+ size?: number;
302
+ }
303
+
304
+ /**
305
+ * 사용자 추방 및 추방 해제 파라미터
306
+ */
307
+ interface CimeRestrictUserParams {
308
+ /** 추방(또는 해제)할 사용자의 채널 ID */
309
+ targetChannelId: string;
310
+ }
311
+ /**
312
+ * 추방 사용자 목록 조회 파라미터
313
+ */
314
+ interface CimeGetRestrictedUsersParams {
315
+ /** 페이지 크기 (1~50, 기본값: 20) */
316
+ size?: number;
317
+ /** 다음 페이지 커서 값 */
318
+ next?: string;
319
+ }
320
+ /**
321
+ * 추방된 사용자 정보
322
+ */
323
+ interface CimeRestrictedUser {
324
+ restrictedChannelId: string;
325
+ restrictedChannelName: string;
326
+ restrictedChannelHandle: string;
327
+ /** 추방 일시 (ISO 8601) */
328
+ createdDate: string;
329
+ /** 추방 만료 일시. 영구 추방 시 null */
330
+ releaseDate: string | null;
331
+ }
332
+
333
+ type CimeSessionType = 'USER' | 'CLIENT';
334
+ type CimeEventName = 'chat' | 'donation' | 'subscription';
335
+ /**
336
+ * 세션 생성 응답
337
+ */
338
+ interface CimeSessionResponse {
339
+ /** WebSocket 연결 URL */
340
+ url: string;
341
+ }
342
+ /**
343
+ * 수신되는 실시간 이벤트 데이터의 공통 구조
344
+ */
345
+ interface CimeEventPayload<T = any> {
346
+ event: 'CHAT' | 'DONATION' | 'SUBSCRIPTION';
347
+ data: T;
348
+ }
349
+ /**
350
+ * EventClient 옵션
351
+ */
352
+ interface CimeEventClientOptions {
353
+ /** 세션 유형 (USER: 인증된 사용자 권한, CLIENT: 앱 공개 권한) */
354
+ type: 'USER' | 'CLIENT';
355
+ /**
356
+ * [SDK 자동 처리]
357
+ * 재연결 시 사용할 Refresh Token.
358
+ * 이 값을 제공하면 재연결 시 자동으로 `auth.refresh()`를 호출하여 토큰을 갱신합니다.
359
+ */
360
+ refreshToken?: string;
361
+ /**
362
+ * [수동 처리]
363
+ * DB 조회 등 커스텀 토큰 갱신 로직이 필요한 경우 직접 작성하는 콜백 함수.
364
+ * `refreshToken` 필드를 사용했다면 이 함수는 생략해도 무방합니다.
365
+ */
366
+ onTokenRefresh?: () => Promise<void>;
367
+ /** 핑(Ping) 전송 간격 (밀리초, 기본값 60000ms = 1분) */
368
+ pingInterval?: number;
369
+ }
370
+
371
+ /**
372
+ * 후원 유형 (채팅 후원 또는 영상 후원)
373
+ */
374
+ type CimeDonationType = 'CHAT' | 'VIDEO';
375
+ /**
376
+ * 실시간 DONATION 이벤트 수신 시 전달되는 데이터 페이로드
377
+ */
378
+ interface CimeDonationEventData {
379
+ /** 후원 유형 */
380
+ donationType: CimeDonationType;
381
+ /** 후원이 발생한 채널의 ID */
382
+ channelId: string;
383
+ /** 후원자의 채널 ID (익명 후원 시 null) */
384
+ donatorChannelId: string | null;
385
+ /** 후원자 닉네임 (익명 후원 시 null) */
386
+ donatorNickname: string | null;
387
+ /** 후원 금액 (빔 단위, 정밀도 손실 방지를 위해 문자열 사용) */
388
+ payAmount: string;
389
+ /** 후원 메시지 */
390
+ donationText: string;
391
+ /** 이모티콘 토큰 -> 이미지 URL 매핑 객체 */
392
+ emojis: Record<string, string>;
393
+ }
394
+
395
+ /**
396
+ * 실시간 SUBSCRIPTION 이벤트 수신 시 전달되는 데이터 페이로드
397
+ */
398
+ interface CimeSubscriptionEventData {
399
+ /** 구독이 발생한 채널의 ID */
400
+ channelId: string;
401
+ /** 구독자의 채널 ID */
402
+ subscriberChannelId: string;
403
+ /** 구독자의 채널 이름 (닉네임) */
404
+ subscriberChannelName: string;
405
+ /** 연속 구독 개월 수 */
406
+ month: number;
407
+ /** 구독 티어 번호 */
408
+ tierNo: number;
409
+ /** 구독 메시지 (이모티콘 토큰 포함 가능) */
410
+ subscriptionMessage: string;
411
+ /** 이모티콘 토큰 -> 이미지 URL 매핑 객체 */
412
+ emojis: Record<string, string>;
413
+ }
414
+
415
+ interface CimeCommonResponse<T = unknown> {
416
+ code: number;
417
+ message: string | null;
418
+ content: T;
419
+ }
420
+ interface CimeErrorResponse {
421
+ statusCode: number;
422
+ message: string;
423
+ }
424
+ interface CimeClientOptions {
425
+ clientId?: string;
426
+ clientSecret?: string;
427
+ accessToken?: string;
428
+ refreshToken?: string;
429
+ scopes?: string[];
430
+ timeout?: number;
431
+ retries?: number;
432
+ }
433
+
434
+ declare class AuthAPI {
435
+ private readonly http;
436
+ private readonly config;
437
+ constructor(http: AxiosInstance, config: {
438
+ clientId?: string;
439
+ clientSecret?: string;
440
+ });
441
+ /**
442
+ * Authorization Code를 사용하여 Access Token과 Refresh Token을 발급받습니다.
443
+ * @param code Redirect URI로 전달받은 인가 코드
444
+ */
445
+ get(code: string): Promise<CimeTokenResponse>;
446
+ /**
447
+ * Refresh Token을 사용하여 Access Token을 갱신합니다.
448
+ * @param refreshToken 이전에 발급받은 리프레시 토큰
449
+ */
450
+ refresh(refreshToken: string): Promise<CimeTokenResponse>;
451
+ /**
452
+ * 내부 헬퍼: 토큰 발급 시 필요한 Client ID 및 Secret 유효성 검사 (Fail-fast)
453
+ */
454
+ private validateCredentials;
455
+ }
456
+
457
+ /**
458
+ * 사용자(User) 관련 API를 담당하는 클래스입니다.
459
+ */
460
+ declare class UsersAPI {
461
+ private readonly httpClient;
462
+ private readonly options;
463
+ constructor(httpClient: AxiosInstance, options: CimeClientOptions);
464
+ /**
465
+ * 현재 Access Token에 연결된 사용자의 채널 정보를 조회합니다.
466
+ *
467
+ * @requires Scope: `READ:USER`
468
+ * @throws {CimeAPIError} Access Token이 없거나 만료되었을 때 (401), 또는 권한이 부족할 때 발생합니다.
469
+ * @returns 사용자의 채널 상세 정보
470
+ * * @example
471
+ * ```typescript
472
+ * const me = await client.users.get();
473
+ * console.log(`안녕하세요, ${me.channelName}님!`);
474
+ * ```
475
+ */
476
+ get(): Promise<CimeUser>;
477
+ }
478
+
479
+ /**
480
+ * 채널(Channel) 관련 API를 담당하는 클래스입니다.
481
+ * 채널 정보, 팔로워, 구독자, 관리자 목록 조회 기능을 제공합니다.
482
+ */
483
+ declare class ChannelsAPI {
484
+ private readonly httpClient;
485
+ private readonly options;
486
+ constructor(httpClient: AxiosInstance, options: CimeClientOptions);
487
+ /**
488
+ * 채널 ID 목록으로 채널의 기본 정보를 조회합니다. (최대 20개)
489
+ *
490
+ * @requires Auth: `Client ID / Secret` (공개 API)
491
+ * @param channelIds - 조회할 채널 ID 문자열 또는 ID 문자열의 배열
492
+ * @returns 채널 정보 목록
493
+ * * @example
494
+ * ```typescript
495
+ * const { data } = await client.channels.getChannels(['12345', '67890']);
496
+ * ```
497
+ */
498
+ getChannels(channelIds: string | string[]): Promise<CimeDataList<CimeChannelInfo>>;
499
+ /**
500
+ * 인증된 사용자 채널의 팔로워 목록을 조회합니다.
501
+ *
502
+ * @requires Auth: `Access Token`
503
+ * @requires Scope: `READ:CHANNEL`
504
+ * @param params - 페이징 파라미터 (page, size)
505
+ * @returns 팔로워 목록
506
+ */
507
+ getFollowers(params?: CimeChannelFollowersParams): Promise<CimeDataList<CimeFollower>>;
508
+ /**
509
+ * 인증된 사용자 채널의 구독자 목록을 조회합니다.
510
+ *
511
+ * @requires Auth: `Access Token`
512
+ * @requires Scope: `READ:SUBSCRIPTION`
513
+ * @param params - 페이징 및 정렬 파라미터 (page, size, sort)
514
+ * @returns 구독자 목록
515
+ */
516
+ getSubscribers(params?: CimeChannelSubscribersParams): Promise<CimeDataList<CimeSubscriber>>;
517
+ /**
518
+ * 인증된 사용자 채널의 관리자 목록을 조회합니다.
519
+ *
520
+ * @requires Auth: `Access Token`
521
+ * @requires Scope: `READ:CHANNEL`
522
+ * @returns 관리자 목록
523
+ */
524
+ getManagers(): Promise<CimeDataList<CimeManager>>;
525
+ }
526
+
527
+ /**
528
+ * 라이브(Live) 및 스트리밍 관련 API를 담당하는 클래스입니다.
529
+ */
530
+ declare class LiveAPI {
531
+ private readonly httpClient;
532
+ private readonly options;
533
+ constructor(httpClient: AxiosInstance, options: CimeClientOptions);
534
+ /**
535
+ * 현재 진행 중인 라이브 방송 목록을 조회합니다.
536
+ *
537
+ * @requires Auth: `Client ID / Secret` (공개 API)
538
+ * @param params - 커서 기반 페이징 파라미터 (size, next)
539
+ * @returns 라이브 목록과 다음 페이지 커서 정보
540
+ */
541
+ getLives(params?: CimeLivesParams): Promise<CimeCursorList<CimeLive>>;
542
+ /**
543
+ * 인증된 사용자 채널의 라이브 설정을 조회합니다.
544
+ *
545
+ * @requires Auth: `Access Token`
546
+ * @requires Scope: `READ:LIVE_STREAM_SETTINGS`
547
+ * @returns 라이브 설정 정보
548
+ */
549
+ getSettings(): Promise<CimeLiveSetting>;
550
+ /**
551
+ * 인증된 사용자 채널의 라이브 설정을 변경합니다. (전달된 필드만 업데이트)
552
+ *
553
+ * @requires Auth: `Access Token`
554
+ * @requires Scope: `WRITE:LIVE_STREAM_SETTINGS`
555
+ * @param params - 변경할 라이브 설정 데이터
556
+ */
557
+ updateSettings(params: CimeUpdateLiveSettingParams): Promise<void>;
558
+ /**
559
+ * 인증된 사용자 채널의 스트림 키(Stream Key)를 조회합니다.
560
+ * OBS 등 외부 방송 도구 연동 시 사용됩니다.
561
+ *
562
+ * @requires Auth: `Access Token`
563
+ * @requires Scope: `READ:LIVE_STREAM_KEY`
564
+ * @returns 스트림 키
565
+ */
566
+ getStreamKey(): Promise<CimeStreamKey>;
567
+ /**
568
+ * 특정 채널의 라이브 방송 여부와 상태를 확인합니다.
569
+ * 이 API는 인증 없이 호출할 수 있는 완전 공개 API입니다.
570
+ *
571
+ * @requires Auth: 불필요
572
+ * @param channelId - 상태를 조회할 채널의 ID
573
+ * @returns 라이브 상태 정보
574
+ */
575
+ getLiveStatus(channelId: string): Promise<CimeLiveStatus>;
576
+ }
577
+
578
+ /**
579
+ * 라이브 채팅(Chat) 설정 및 메시지 전송 관련 API를 담당하는 클래스입니다.
580
+ */
581
+ declare class ChatAPI {
582
+ private readonly httpClient;
583
+ private readonly options;
584
+ constructor(httpClient: AxiosInstance, options: CimeClientOptions);
585
+ /**
586
+ * 인증된 사용자 채널의 채팅 설정을 조회합니다.
587
+ *
588
+ * @requires Auth: `Access Token`
589
+ * @requires Scope: `READ:LIVE_CHAT_SETTINGS`
590
+ * @returns 채팅 설정 정보
591
+ */
592
+ getSettings(): Promise<CimeChatSettings>;
593
+ /**
594
+ * 인증된 사용자 채널의 채팅 설정을 변경합니다. (전달된 필드만 업데이트)
595
+ *
596
+ * @requires Auth: `Access Token`
597
+ * @requires Scope: `WRITE:LIVE_CHAT_SETTINGS`
598
+ * @param params - 변경할 채팅 설정 데이터
599
+ */
600
+ updateSettings(params: CimeUpdateChatSettingsParams): Promise<void>;
601
+ /**
602
+ * 인증된 사용자의 채널 라이브 채팅에 메시지를 전송합니다.
603
+ *
604
+ * @requires Auth: `Access Token`
605
+ * @requires Scope: `WRITE:LIVE_CHAT`
606
+ * @param params - 전송할 메시지 정보 및 발신자 타입
607
+ * @returns 전송된 메시지 ID
608
+ */
609
+ sendMessage(params: CimeSendChatMessageParams): Promise<CimeSendChatMessageResponse>;
610
+ /**
611
+ * 인증된 사용자의 채널 라이브 채팅에 공지사항을 등록합니다.
612
+ *
613
+ * @requires Auth: `Access Token`
614
+ * @requires Scope: `WRITE:LIVE_CHAT_NOTICE`
615
+ * @param params - 등록할 공지 메시지 내용 또는 기존 메시지 ID
616
+ * @throws {Error} 파라미터가 모두 누락된 경우 서버 요청 전 사전 차단합니다.
617
+ */
618
+ registerNotice(params: CimeRegisterChatNoticeParams): Promise<void>;
619
+ }
620
+
621
+ /**
622
+ * 카테고리(Category) 관련 API를 담당하는 클래스입니다.
623
+ */
624
+ declare class CategoriesAPI {
625
+ private readonly httpClient;
626
+ constructor(httpClient: AxiosInstance);
627
+ /**
628
+ * 라이브 설정 등에 사용할 카테고리를 키워드로 검색합니다.
629
+ *
630
+ * @requires Auth: `Client ID / Secret` (공개 API)
631
+ * @param params - 검색 키워드 및 페이지 크기 파라미터
632
+ * @returns 검색된 카테고리 목록
633
+ */
634
+ searchCategories(params?: CimeSearchCategoriesParams): Promise<CimeDataList<CimeCategory>>;
635
+ }
636
+
637
+ /**
638
+ * 사용자 차단 및 추방(Restrict) 관련 API를 담당하는 클래스입니다.
639
+ */
640
+ declare class RestrictAPI {
641
+ private readonly httpClient;
642
+ private readonly options;
643
+ constructor(httpClient: AxiosInstance, options: CimeClientOptions);
644
+ /**
645
+ * 인증된 사용자의 채널에서 특정 사용자를 추방합니다.
646
+ *
647
+ * @requires Auth: `Access Token`
648
+ * @requires Scope: `WRITE:USER_BLOCK`
649
+ * @param params - 추방할 대상 채널 ID
650
+ */
651
+ restrictUser(params: CimeRestrictUserParams): Promise<void>;
652
+ /**
653
+ * 인증된 사용자의 채널에서 추방된 사용자 목록을 조회합니다.
654
+ *
655
+ * @requires Auth: `Access Token`
656
+ * @requires Scope: `READ:USER_BLOCK`
657
+ * @param params - 커서 기반 페이징 파라미터 (size, next)
658
+ * @returns 추방된 사용자 목록
659
+ */
660
+ getRestrictedUsers(params?: CimeGetRestrictedUsersParams): Promise<CimeCursorList<CimeRestrictedUser>>;
661
+ /**
662
+ * 인증된 사용자의 채널에서 특정 사용자의 추방을 해제합니다.
663
+ *
664
+ * @requires Auth: `Access Token`
665
+ * @requires Scope: `WRITE:USER_BLOCK`
666
+ * @param params - 추방 해제할 대상 채널 ID
667
+ */
668
+ unrestrictUser(params: CimeRestrictUserParams): Promise<void>;
669
+ }
670
+
671
+ /**
672
+ * 세션(Session) 및 이벤트 구독 제어를 담당하는 클래스입니다.
673
+ */
674
+ declare class SessionsAPI {
675
+ private readonly httpClient;
676
+ constructor(httpClient: AxiosInstance);
677
+ /**
678
+ * WebSocket 연결을 위한 새로운 세션을 생성합니다.
679
+ *
680
+ * @param type - 세션 유형 ('USER' 또는 'CLIENT')
681
+ * @returns WebSocket URL을 포함한 세션 정보
682
+ */
683
+ createSession(type: CimeSessionType): Promise<CimeSessionResponse>;
684
+ /**
685
+ * 특정 세션에 이벤트를 구독합니다.
686
+ *
687
+ * @requires Auth: `Access Token`
688
+ * @param event - 구독할 이벤트 이름 (chat, donation, subscription)
689
+ * @param sessionKey - 세션 키
690
+ */
691
+ subscribeEvent(event: CimeEventName, sessionKey: string): Promise<void>;
692
+ /**
693
+ * 특정 세션에서 이벤트 구독을 해제합니다.
694
+ *
695
+ * @requires Auth: `Access Token`
696
+ * @param event - 구독 해제할 이벤트 이름
697
+ * @param sessionKey - 세션 키
698
+ */
699
+ unsubscribeEvent(event: CimeEventName, sessionKey: string): Promise<void>;
700
+ }
701
+
702
+ type CimeLiveEventName = 'CHAT' | 'DONATION' | 'SUBSCRIPTION';
703
+ declare interface CimeEventClient {
704
+ on(event: 'CHAT', listener: (data: CimeChatEventData) => void): this;
705
+ on(event: 'DONATION', listener: (data: CimeDonationEventData) => void): this;
706
+ on(event: 'SUBSCRIPTION', listener: (data: CimeSubscriptionEventData) => void): this;
707
+ on(event: 'connected', listener: () => void): this;
708
+ on(event: 'disconnected', listener: () => void): this;
709
+ on(event: 'error', listener: (error: Error) => void): this;
710
+ on(event: 'reconnecting', listener: () => void): this;
711
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
712
+ emit(event: 'CHAT', data: CimeChatEventData): boolean;
713
+ emit(event: 'DONATION', data: CimeDonationEventData): boolean;
714
+ emit(event: 'SUBSCRIPTION', data: CimeSubscriptionEventData): boolean;
715
+ emit(event: 'connected'): boolean;
716
+ emit(event: 'disconnected'): boolean;
717
+ emit(event: 'error', error: Error): boolean;
718
+ emit(event: 'reconnecting'): boolean;
719
+ emit(event: string | symbol, ...args: any[]): boolean;
720
+ }
721
+ /**
722
+ * ci.me API의 실시간 이벤트를 수신하기 위한 WebSocket 클라이언트입니다.
723
+ */
724
+ declare class CimeEventClient extends EventEmitter {
725
+ private readonly sessionsApi;
726
+ private readonly options;
727
+ private ws;
728
+ private sessionKey;
729
+ private pingTimer;
730
+ private reconnectTimer;
731
+ private isConnecting;
732
+ private isIntentionalClose;
733
+ private readonly activeSubscriptions;
734
+ constructor(sessionsApi: SessionsAPI, options: CimeEventClientOptions);
735
+ connect(): Promise<void>;
736
+ /**
737
+ * 실시간 이벤트를 구독합니다.
738
+ * @param event - 'CHAT' | 'DONATION' | 'SUBSCRIPTION'
739
+ */
740
+ subscribe(event: CimeLiveEventName): Promise<void>;
741
+ /**
742
+ * 실시간 이벤트 구독을 해제합니다.
743
+ * @param event - 'CHAT' | 'DONATION' | 'SUBSCRIPTION'
744
+ */
745
+ unsubscribe(event: CimeLiveEventName): Promise<void>;
746
+ disconnect(): void;
747
+ private handleMessage;
748
+ private startPing;
749
+ private cleanup;
750
+ private handleReconnect;
751
+ }
752
+
753
+ /**
754
+ * ci.me API를 사용하기 위한 메인 클라이언트 클래스입니다.
755
+ */
756
+ declare class CimeClient {
757
+ private readonly httpClient;
758
+ private options;
759
+ readonly auth: AuthAPI;
760
+ readonly users: UsersAPI;
761
+ readonly channels: ChannelsAPI;
762
+ readonly live: LiveAPI;
763
+ readonly chat: ChatAPI;
764
+ readonly categories: CategoriesAPI;
765
+ readonly restrict: RestrictAPI;
766
+ readonly sessions: SessionsAPI;
767
+ constructor(options: CimeClientOptions);
768
+ setAccessToken(token: string): void;
769
+ /**
770
+ * 실시간 이벤트를 수신하기 위한 WebSocket 클라이언트를 생성합니다.
771
+ */
772
+ createEventClient(options: CimeEventClientOptions): CimeEventClient;
773
+ /** * OAuth 인증 플로우를 통해 Access Token을 발급받고 클라이언트에 설정합니다.
774
+ * @param code Redirect URI로 전달받은 인가 코드
775
+ * @throws 인증 정보(clientId/Secret)가 없으면 에러를 반환합니다.
776
+ */
777
+ authorize(code: string): Promise<CimeTokenResponse>;
778
+ }
779
+
780
+ /**
781
+ * ci.me API 요청 중 발생하는 에러를 캡슐화한 커스텀 에러 클래스입니다.
782
+ * HTTP 상태 코드와 API가 반환한 상세 메시지를 포함합니다.
783
+ */
784
+ declare class CimeAPIError extends Error {
785
+ readonly statusCode: number;
786
+ /**
787
+ * @param errorResponse - API 서버에서 반환한 에러 객체
788
+ */
789
+ constructor(errorResponse: CimeErrorResponse);
790
+ }
791
+
792
+ /**
793
+ * 채팅 메시지 내의 이모티콘 토큰을 <img> 태그로 변환합니다.
794
+ * 따로 UI를 만드실 계획이 아니시라면, 별 쓸모는 없습니다.
795
+ * @param data 채팅 이벤트 데이터 (content, emojis)
796
+ * @param className <img> 태그에 부여할 CSS 클래스명 (기본값: 'cime-emoji')
797
+ * @returns 변환된 HTML 문자열
798
+ */
799
+ declare function renderChatEmojisToHTML(data: Pick<CimeChatEventData, 'content' | 'emojis'>, className?: string): string;
800
+
801
+ /**
802
+ * 로컬 패키지의 현재 버전을 반환합니다.
803
+ */
804
+ declare function getVersion(): string;
805
+
806
+ export { CimeAPIError, type CimeCategory, type CimeChannelFollowersParams, type CimeChannelInfo, type CimeChannelSubscribersParams, type CimeChatAllowedGroup, type CimeChatEventData, type CimeChatProfile, type CimeChatSettings, CimeClient, type CimeClientOptions, type CimeCommonResponse, type CimeCursorList, type CimeCursorPage, type CimeDataList, type CimeDonationEventData, type CimeDonationType, type CimeErrorResponse, CimeEventClient, type CimeEventClientOptions, type CimeEventName, type CimeEventPayload, type CimeFollower, type CimeGetRestrictedUsersParams, type CimeLive, type CimeLiveEventName, type CimeLiveSetting, type CimeLiveStatus, type CimeLivesParams, type CimeManager, type CimeRegisterChatNoticeParams, type CimeRestrictUserParams, type CimeRestrictedUser, type CimeRevokeTokenRequest, type CimeScope, type CimeSearchCategoriesParams, type CimeSendChatMessageParams, type CimeSendChatMessageResponse, type CimeSessionResponse, type CimeSessionType, type CimeStreamKey, type CimeStreamingRole, type CimeSubscriber, type CimeSubscriptionEventData, type CimeTokenRequest, type CimeTokenResponse, type CimeUpdateChatSettingsParams, type CimeUpdateLiveSettingParams, type CimeUser, getVersion, renderChatEmojisToHTML };