@vibexnpm/talkx 7.3.0 → 8.1.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.
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  채팅 + WebRTC + 웹 푸시 통합 JavaScript SDK.
4
4
 
5
+ 로그인·새로고침 복구·FE 인증 상태 연동은 [Refresh 세션 가이드](docs/REFRESH_AUTH.md)를 따릅니다. 새 서버의 refresh API가 필요합니다.
6
+
5
7
  ```bash
6
8
  npm install @vibexnpm/talkflow
7
9
  ```
package/dist/index.d.ts CHANGED
@@ -1036,8 +1036,14 @@ export interface LoginMember {
1036
1036
  * 회사 선택 단계가 없다 — 로그인 키가 전역 유일이라 이메일 하나로 회원과 회사가 함께 정해진다.
1037
1037
  */
1038
1038
  export interface LoginResult {
1039
+ /** SDK가 저장·회전하는 갱신 자격. 직접 API를 쓰는 경우에만 응답에서 사용한다. */
1040
+ refreshToken?: string;
1041
+ /** 서버 현재 시각 및 refresh 만료 시각, Unix epoch 밀리초. */
1042
+ serverTime?: number;
1043
+ refreshExpiresAt?: number;
1039
1044
  accessToken: string;
1040
1045
  tokenType: string;
1046
+ /** Access 만료 시각, Unix epoch 초(남은 시간 아님). */
1041
1047
  expiresIn?: number;
1042
1048
  projectId: string;
1043
1049
  /** 회사의 활성 ck- 키. SDK 초기화의 `apiKey` 로 그대로 넣는다. */
@@ -1464,11 +1470,16 @@ export interface AssistantProgressSnapshot extends AssistantRoomProgressEvent {
1464
1470
  // Options — constructor & method
1465
1471
  // ============================================================================
1466
1472
 
1473
+ export type AuthState = 'checking' | 'authenticated' | 'unauthenticated' | 'unavailable';
1474
+ export interface AccessTokenOptions { forceRefresh?: boolean; rejectedToken?: string; }
1475
+
1467
1476
  export interface TalkFlowClientOptions {
1468
1477
  /** Client API 키 (브라우저 노출 안전). */
1469
- apiKey: string;
1478
+ apiKey?: string;
1470
1479
  /** 프로젝트 ID. */
1471
- projectId: string;
1480
+ projectId?: string;
1481
+ /** refresh: 키 없이 생성 후 restoreSession/loginUser 가능. 기존 JWT만 쓰면 legacy. */
1482
+ sessionMode?: 'refresh' | 'legacy';
1472
1483
  /** JWT 토큰 — 고객사 backend 에서 발급 받아 전달. */
1473
1484
  jwtToken?: string;
1474
1485
  /** 환경. 기본 'production'. */
@@ -1867,6 +1878,8 @@ export interface TalkFlowClientEvents {
1867
1878
  connectionError: unknown;
1868
1879
  tokenSet: { userId: string };
1869
1880
  loggedOut: void;
1881
+ authStateChanged: { state: AuthState; previous: AuthState; error?: unknown };
1882
+ authError: unknown;
1870
1883
 
1871
1884
  // Chat (re-emit from ChatClient with prefixed names)
1872
1885
  chatMessage: ChatMessageReceivedPayload;
@@ -2432,6 +2445,18 @@ export default class TalkFlowClient implements SdkEventEmitter<TalkFlowClientEve
2432
2445
  /** 회원 로그인 (인스턴스) — 재로그인·계정 전환용. 성공 시 토큰을 자동 설정한다. */
2433
2446
  loginUser(credentials: { email: string; password: string }): Promise<LoginResult>;
2434
2447
 
2448
+ /** localStorage의 refresh로 복구. 세션이 없으면 null, 네트워크/서버 장애는 reject. */
2449
+ static restoreSession(options: { serverUrl: string }): Promise<LoginResult | null>;
2450
+ restoreSession(): Promise<LoginResult | null>;
2451
+ /** 캐시된 UI 상태. 호출 자체는 통신하지 않으며 서버 권한 판정은 요청 시 수행된다. */
2452
+ getAuthState(): AuthState;
2453
+ isLoggedIn(): boolean;
2454
+ /** 유효한 메모리 토큰 반환. 필요할 때만 갱신하며 동시 요청은 하나로 합친다. */
2455
+ getAccessToken(options?: AccessTokenOptions): Promise<string>;
2456
+ /** 관리/캘린더 등 SDK 밖 호출용. 토큰 준비와 인증 오류 1회 재시도를 공통 적용한다. */
2457
+ request<T = unknown>(method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', path: string,
2458
+ options?: { body?: unknown; params?: Record<string, unknown>; headers?: Record<string, string> }): Promise<T>;
2459
+
2435
2460
  /** 내 정보 조회. */
2436
2461
  getMyProfile(): Promise<MyProfile>;
2437
2462
 
@@ -2448,7 +2473,7 @@ export default class TalkFlowClient implements SdkEventEmitter<TalkFlowClientEve
2448
2473
  timeZone?: string;
2449
2474
  }): Promise<MyProfile>;
2450
2475
 
2451
- /** 비밀번호 변경 — 현재 비밀번호 재확인. 토큰은 그대로 유효해 재로그인이 필요 없다. */
2476
+ /** 비밀번호 변경 — 기존 세션을 모두 폐기하고 이 브라우저에 새 세션을 자동 채택한다. */
2452
2477
  changeMyPassword(params: { currentPassword: string; newPassword: string }): Promise<unknown>;
2453
2478
 
2454
2479
  // Connection lifecycle