connectbase-client 3.26.0 → 3.27.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.
package/dist/index.d.mts CHANGED
@@ -12,6 +12,30 @@ declare class ApiError extends Error {
12
12
  declare class AuthError extends Error {
13
13
  constructor(message: string);
14
14
  }
15
+ /**
16
+ * `cb.auth.signInAsGuestMember()` 호출 시 이미 활성화된 비-게스트 세션이 감지되면 발생.
17
+ *
18
+ * 같은 origin + 같은 publicKey 에서 OAuth/Email 로그인이 살아있는 상태로
19
+ * 우발적으로 게스트 로그인이 호출되면 메인 토큰 슬롯이 silent 로 덮어써지는
20
+ * 회귀(platform-issue 019e6c5d)를 차단하기 위한 가드.
21
+ *
22
+ * 명시적으로 활성 세션을 게스트로 교체하려면 `{ allowOverrideExistingSession: true }` 를
23
+ * 옵션으로 넘기거나, 먼저 `cb.auth.signOut()` 으로 정리할 것.
24
+ *
25
+ * ```ts
26
+ * try {
27
+ * await cb.auth.signInAsGuestMember()
28
+ * } catch (e) {
29
+ * if (e instanceof GuestSessionConflictError) {
30
+ * // 이미 로그인된 사용자가 있다는 뜻 — 게스트로 강제 전환할지 사용자에게 물어볼 것
31
+ * }
32
+ * }
33
+ * ```
34
+ */
35
+ declare class GuestSessionConflictError extends Error {
36
+ code: string;
37
+ constructor();
38
+ }
15
39
  /**
16
40
  * GameError 는 game-server 가 surface 한 `error` 메시지 (createRoom/joinRoom/sendAction
17
41
  * 응답 또는 broadcastScriptError) 를 client 측에서 일관된 형태로 다루기 위한 예외 클래스.
@@ -762,6 +786,20 @@ interface MemberInfoResponse {
762
786
  email?: string;
763
787
  /** 멤버 역할 — RLS 규칙에서 `auth.role` 로 참조 (예: "admin", "moderator") */
764
788
  role?: string;
789
+ /**
790
+ * 현재 세션이 게스트(자동 생성된 익명 멤버)인지 여부.
791
+ * `cb.auth.signInAsGuestMember()` 로 만들어진 멤버 또는 identity 가 전혀 없는
792
+ * 멤버는 true. 게스트 둔갑(silent overwrite) 감지/복구용 결정적 신호다.
793
+ */
794
+ is_guest?: boolean;
795
+ /**
796
+ * 현재 세션의 인증 방식 식별자.
797
+ * "guest" | "email" | "username" | "oauth_google" | "oauth_kakao" |
798
+ * "oauth_naver" | "oauth_apple" | "oauth_github" | "oauth_discord"
799
+ * OAuth 외 미래 provider 가 추가되면 동일한 `oauth_<provider>` 컨벤션을 따른다.
800
+ * identity 가 전혀 없는 경우 빈 문자열.
801
+ */
802
+ auth_provider?: string;
765
803
  }
766
804
  /** 앱 멤버 custom_data 수정 요청 */
767
805
  interface UpdateCustomDataRequest {
@@ -782,6 +820,20 @@ interface AuthSettingsResponse {
782
820
  enabled_oauth_providers: string[];
783
821
  }
784
822
 
823
+ /**
824
+ * `signInAsGuestMember()` 의 동작을 제어하는 옵션.
825
+ *
826
+ * `allowOverrideExistingSession` 가 false(또는 미지정) 이고 활성 비-게스트 세션이
827
+ * 감지되면 `GuestSessionConflictError` 가 발생한다. true 로 명시해야만 silent
828
+ * overwrite 가 허용된다 (platform-issue 019e6c5d 가드).
829
+ */
830
+ interface SignInAsGuestMemberOptions {
831
+ /**
832
+ * 이미 활성화된 비-게스트(OAuth/email/username) 세션이 있어도 게스트 토큰으로
833
+ * 덮어쓸지 여부. 기본값 false — 호출이 거부된다.
834
+ */
835
+ allowOverrideExistingSession?: boolean;
836
+ }
785
837
  declare class AuthAPI {
786
838
  private http;
787
839
  private guestMemberLoginPromise;
@@ -847,13 +899,37 @@ declare class AuthAPI {
847
899
  * 로컬 스토리지에 저장된 토큰이 있으면 기존 계정으로 재로그인을 시도합니다.
848
900
  * 동시 호출 시 중복 요청 방지 (race condition 방지)
849
901
  *
902
+ * **활성 세션 가드 (3.22.0+)**
903
+ * OAuth/email/username 로 이미 로그인된 세션이 살아있는 채 이 메서드가 호출되면
904
+ * 메인 토큰 슬롯이 silent 로 게스트 토큰으로 덮어써져 사용자가 둔갑되는 회귀가
905
+ * 있었다 (platform-issue 019e6c5d). 이를 막기 위해 활성 비-게스트 세션이 감지되면
906
+ * 기본적으로 `GuestSessionConflictError` 를 던진다. 명시적으로 교체하려면
907
+ * `{ allowOverrideExistingSession: true }` 를 전달하거나 먼저 `signOut()` 을 호출할 것.
908
+ *
850
909
  * @example
851
910
  * ```typescript
852
911
  * const guest = await client.auth.signInAsGuestMember()
853
912
  * await client.realtime.connect({ accessToken: guest.access_token })
913
+ *
914
+ * // 활성 세션을 명시적으로 교체 (예: "게스트로 계속" 버튼)
915
+ * await client.auth.signInAsGuestMember({ allowOverrideExistingSession: true })
854
916
  * ```
855
917
  */
856
- signInAsGuestMember(): Promise<GuestMemberSignInResponse>;
918
+ signInAsGuestMember(opts?: SignInAsGuestMemberOptions): Promise<GuestMemberSignInResponse>;
919
+ /**
920
+ * 현재 in-memory access token 이 "게스트 토큰이 아닌 다른 세션" 으로 판단되는지 확인.
921
+ *
922
+ * 판별 규칙:
923
+ * - access token 자체가 없으면 false (어떤 세션도 없음)
924
+ * - access token 이 만료됐으면 false (재로그인이 필요한 dead 상태)
925
+ * - persistence='none' 인 경우: 토큰은 메모리에만 존재. 우리는 그 토큰이
926
+ * 게스트인지 회원인지 분별할 메타가 메모리에 없다 → 보수적으로 true 처리.
927
+ * (회원이 가지고 있던 세션을 게스트가 덮어쓰는 게 더 큰 사고이므로
928
+ * false-positive < silent overwrite.)
929
+ * - persistence='localStorage'|'sessionStorage' 인 경우: 저장된 게스트 토큰과
930
+ * 현재 access token 이 일치하면 게스트 세션(false), 다르면 비-게스트(true).
931
+ */
932
+ private hasActiveNonGuestSession;
857
933
  /**
858
934
  * 현재 로그인한 멤버 정보 조회
859
935
  * custom_data를 포함한 멤버 정보를 반환합니다.
@@ -7493,6 +7569,8 @@ interface AIStreamChunk {
7493
7569
  success?: boolean;
7494
7570
  durationMs?: number;
7495
7571
  searching?: AgenticSearchProgress;
7572
+ error?: string;
7573
+ message?: string;
7496
7574
  }
7497
7575
 
7498
7576
  /**
@@ -8700,4 +8778,4 @@ declare class ConnectBase {
8700
8778
  updateConfig(config: Partial<ConnectBaseConfig>): void;
8701
8779
  }
8702
8780
 
8703
- export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, AUTH_MEMBER_ID_TOKEN, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AgenticSearchProgress, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchOperationResult, type BatchSetPageMetaRequest, type BatchWriteResult, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateRoomResult, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConfig, GameConfigAPI, type GameConfigPatch, type GameConnectionState, type GameConnectionStatus, type GameDelta, GameError, type GameErrorCode, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PollUntilOptions, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStaleMessage, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamContentPart, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamImageURLPart, type StreamMessage, type StreamOptions, type StreamSession, type StreamTextPart, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionResult, type TransactionWrite, type TransactionWriteResult, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateDocumentRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, detectInAppBrowser, escapeToExternalBrowser, isWebTransportSupported, toCreateRoomWire };
8781
+ export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, AUTH_MEMBER_ID_TOKEN, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AgenticSearchProgress, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchOperationResult, type BatchSetPageMetaRequest, type BatchWriteResult, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateRoomResult, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConfig, GameConfigAPI, type GameConfigPatch, type GameConnectionState, type GameConnectionStatus, type GameDelta, GameError, type GameErrorCode, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, GuestSessionConflictError, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PollUntilOptions, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStaleMessage, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamContentPart, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamImageURLPart, type StreamMessage, type StreamOptions, type StreamSession, type StreamTextPart, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionResult, type TransactionWrite, type TransactionWriteResult, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateDocumentRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, detectInAppBrowser, escapeToExternalBrowser, isWebTransportSupported, toCreateRoomWire };
package/dist/index.d.ts CHANGED
@@ -12,6 +12,30 @@ declare class ApiError extends Error {
12
12
  declare class AuthError extends Error {
13
13
  constructor(message: string);
14
14
  }
15
+ /**
16
+ * `cb.auth.signInAsGuestMember()` 호출 시 이미 활성화된 비-게스트 세션이 감지되면 발생.
17
+ *
18
+ * 같은 origin + 같은 publicKey 에서 OAuth/Email 로그인이 살아있는 상태로
19
+ * 우발적으로 게스트 로그인이 호출되면 메인 토큰 슬롯이 silent 로 덮어써지는
20
+ * 회귀(platform-issue 019e6c5d)를 차단하기 위한 가드.
21
+ *
22
+ * 명시적으로 활성 세션을 게스트로 교체하려면 `{ allowOverrideExistingSession: true }` 를
23
+ * 옵션으로 넘기거나, 먼저 `cb.auth.signOut()` 으로 정리할 것.
24
+ *
25
+ * ```ts
26
+ * try {
27
+ * await cb.auth.signInAsGuestMember()
28
+ * } catch (e) {
29
+ * if (e instanceof GuestSessionConflictError) {
30
+ * // 이미 로그인된 사용자가 있다는 뜻 — 게스트로 강제 전환할지 사용자에게 물어볼 것
31
+ * }
32
+ * }
33
+ * ```
34
+ */
35
+ declare class GuestSessionConflictError extends Error {
36
+ code: string;
37
+ constructor();
38
+ }
15
39
  /**
16
40
  * GameError 는 game-server 가 surface 한 `error` 메시지 (createRoom/joinRoom/sendAction
17
41
  * 응답 또는 broadcastScriptError) 를 client 측에서 일관된 형태로 다루기 위한 예외 클래스.
@@ -762,6 +786,20 @@ interface MemberInfoResponse {
762
786
  email?: string;
763
787
  /** 멤버 역할 — RLS 규칙에서 `auth.role` 로 참조 (예: "admin", "moderator") */
764
788
  role?: string;
789
+ /**
790
+ * 현재 세션이 게스트(자동 생성된 익명 멤버)인지 여부.
791
+ * `cb.auth.signInAsGuestMember()` 로 만들어진 멤버 또는 identity 가 전혀 없는
792
+ * 멤버는 true. 게스트 둔갑(silent overwrite) 감지/복구용 결정적 신호다.
793
+ */
794
+ is_guest?: boolean;
795
+ /**
796
+ * 현재 세션의 인증 방식 식별자.
797
+ * "guest" | "email" | "username" | "oauth_google" | "oauth_kakao" |
798
+ * "oauth_naver" | "oauth_apple" | "oauth_github" | "oauth_discord"
799
+ * OAuth 외 미래 provider 가 추가되면 동일한 `oauth_<provider>` 컨벤션을 따른다.
800
+ * identity 가 전혀 없는 경우 빈 문자열.
801
+ */
802
+ auth_provider?: string;
765
803
  }
766
804
  /** 앱 멤버 custom_data 수정 요청 */
767
805
  interface UpdateCustomDataRequest {
@@ -782,6 +820,20 @@ interface AuthSettingsResponse {
782
820
  enabled_oauth_providers: string[];
783
821
  }
784
822
 
823
+ /**
824
+ * `signInAsGuestMember()` 의 동작을 제어하는 옵션.
825
+ *
826
+ * `allowOverrideExistingSession` 가 false(또는 미지정) 이고 활성 비-게스트 세션이
827
+ * 감지되면 `GuestSessionConflictError` 가 발생한다. true 로 명시해야만 silent
828
+ * overwrite 가 허용된다 (platform-issue 019e6c5d 가드).
829
+ */
830
+ interface SignInAsGuestMemberOptions {
831
+ /**
832
+ * 이미 활성화된 비-게스트(OAuth/email/username) 세션이 있어도 게스트 토큰으로
833
+ * 덮어쓸지 여부. 기본값 false — 호출이 거부된다.
834
+ */
835
+ allowOverrideExistingSession?: boolean;
836
+ }
785
837
  declare class AuthAPI {
786
838
  private http;
787
839
  private guestMemberLoginPromise;
@@ -847,13 +899,37 @@ declare class AuthAPI {
847
899
  * 로컬 스토리지에 저장된 토큰이 있으면 기존 계정으로 재로그인을 시도합니다.
848
900
  * 동시 호출 시 중복 요청 방지 (race condition 방지)
849
901
  *
902
+ * **활성 세션 가드 (3.22.0+)**
903
+ * OAuth/email/username 로 이미 로그인된 세션이 살아있는 채 이 메서드가 호출되면
904
+ * 메인 토큰 슬롯이 silent 로 게스트 토큰으로 덮어써져 사용자가 둔갑되는 회귀가
905
+ * 있었다 (platform-issue 019e6c5d). 이를 막기 위해 활성 비-게스트 세션이 감지되면
906
+ * 기본적으로 `GuestSessionConflictError` 를 던진다. 명시적으로 교체하려면
907
+ * `{ allowOverrideExistingSession: true }` 를 전달하거나 먼저 `signOut()` 을 호출할 것.
908
+ *
850
909
  * @example
851
910
  * ```typescript
852
911
  * const guest = await client.auth.signInAsGuestMember()
853
912
  * await client.realtime.connect({ accessToken: guest.access_token })
913
+ *
914
+ * // 활성 세션을 명시적으로 교체 (예: "게스트로 계속" 버튼)
915
+ * await client.auth.signInAsGuestMember({ allowOverrideExistingSession: true })
854
916
  * ```
855
917
  */
856
- signInAsGuestMember(): Promise<GuestMemberSignInResponse>;
918
+ signInAsGuestMember(opts?: SignInAsGuestMemberOptions): Promise<GuestMemberSignInResponse>;
919
+ /**
920
+ * 현재 in-memory access token 이 "게스트 토큰이 아닌 다른 세션" 으로 판단되는지 확인.
921
+ *
922
+ * 판별 규칙:
923
+ * - access token 자체가 없으면 false (어떤 세션도 없음)
924
+ * - access token 이 만료됐으면 false (재로그인이 필요한 dead 상태)
925
+ * - persistence='none' 인 경우: 토큰은 메모리에만 존재. 우리는 그 토큰이
926
+ * 게스트인지 회원인지 분별할 메타가 메모리에 없다 → 보수적으로 true 처리.
927
+ * (회원이 가지고 있던 세션을 게스트가 덮어쓰는 게 더 큰 사고이므로
928
+ * false-positive < silent overwrite.)
929
+ * - persistence='localStorage'|'sessionStorage' 인 경우: 저장된 게스트 토큰과
930
+ * 현재 access token 이 일치하면 게스트 세션(false), 다르면 비-게스트(true).
931
+ */
932
+ private hasActiveNonGuestSession;
857
933
  /**
858
934
  * 현재 로그인한 멤버 정보 조회
859
935
  * custom_data를 포함한 멤버 정보를 반환합니다.
@@ -7493,6 +7569,8 @@ interface AIStreamChunk {
7493
7569
  success?: boolean;
7494
7570
  durationMs?: number;
7495
7571
  searching?: AgenticSearchProgress;
7572
+ error?: string;
7573
+ message?: string;
7496
7574
  }
7497
7575
 
7498
7576
  /**
@@ -8700,4 +8778,4 @@ declare class ConnectBase {
8700
8778
  updateConfig(config: Partial<ConnectBaseConfig>): void;
8701
8779
  }
8702
8780
 
8703
- export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, AUTH_MEMBER_ID_TOKEN, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AgenticSearchProgress, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchOperationResult, type BatchSetPageMetaRequest, type BatchWriteResult, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateRoomResult, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConfig, GameConfigAPI, type GameConfigPatch, type GameConnectionState, type GameConnectionStatus, type GameDelta, GameError, type GameErrorCode, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PollUntilOptions, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStaleMessage, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamContentPart, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamImageURLPart, type StreamMessage, type StreamOptions, type StreamSession, type StreamTextPart, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionResult, type TransactionWrite, type TransactionWriteResult, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateDocumentRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, detectInAppBrowser, escapeToExternalBrowser, isWebTransportSupported, toCreateRoomWire };
8781
+ export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, AUTH_MEMBER_ID_TOKEN, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AgenticSearchProgress, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchOperationResult, type BatchSetPageMetaRequest, type BatchWriteResult, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateRoomResult, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConfig, GameConfigAPI, type GameConfigPatch, type GameConnectionState, type GameConnectionStatus, type GameDelta, GameError, type GameErrorCode, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, GuestSessionConflictError, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PollUntilOptions, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStaleMessage, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamContentPart, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamImageURLPart, type StreamMessage, type StreamOptions, type StreamSession, type StreamTextPart, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionResult, type TransactionWrite, type TransactionWriteResult, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateDocumentRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, detectInAppBrowser, escapeToExternalBrowser, isWebTransportSupported, toCreateRoomWire };
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ __export(index_exports, {
32
32
  GameError: () => GameError,
33
33
  GameRoom: () => GameRoom,
34
34
  GameRoomTransport: () => GameRoomTransport,
35
+ GuestSessionConflictError: () => GuestSessionConflictError,
35
36
  NativeAPI: () => NativeAPI,
36
37
  SessionManager: () => SessionManager,
37
38
  VideoProcessingError: () => VideoProcessingError,
@@ -59,6 +60,15 @@ var AuthError = class extends Error {
59
60
  this.name = "AuthError";
60
61
  }
61
62
  };
63
+ var GuestSessionConflictError = class extends Error {
64
+ constructor() {
65
+ super(
66
+ "signInAsGuestMember refused: an active non-guest session is present in this client. Pass { allowOverrideExistingSession: true } to explicitly replace it, or call signOut() first."
67
+ );
68
+ this.code = "GUEST_SESSION_CONFLICT";
69
+ this.name = "GuestSessionConflictError";
70
+ }
71
+ };
62
72
  var GameError = class extends Error {
63
73
  constructor(init) {
64
74
  super(init.message || init.code || "GameError");
@@ -912,16 +922,29 @@ var AuthAPI = class {
912
922
  * 로컬 스토리지에 저장된 토큰이 있으면 기존 계정으로 재로그인을 시도합니다.
913
923
  * 동시 호출 시 중복 요청 방지 (race condition 방지)
914
924
  *
925
+ * **활성 세션 가드 (3.22.0+)**
926
+ * OAuth/email/username 로 이미 로그인된 세션이 살아있는 채 이 메서드가 호출되면
927
+ * 메인 토큰 슬롯이 silent 로 게스트 토큰으로 덮어써져 사용자가 둔갑되는 회귀가
928
+ * 있었다 (platform-issue 019e6c5d). 이를 막기 위해 활성 비-게스트 세션이 감지되면
929
+ * 기본적으로 `GuestSessionConflictError` 를 던진다. 명시적으로 교체하려면
930
+ * `{ allowOverrideExistingSession: true }` 를 전달하거나 먼저 `signOut()` 을 호출할 것.
931
+ *
915
932
  * @example
916
933
  * ```typescript
917
934
  * const guest = await client.auth.signInAsGuestMember()
918
935
  * await client.realtime.connect({ accessToken: guest.access_token })
936
+ *
937
+ * // 활성 세션을 명시적으로 교체 (예: "게스트로 계속" 버튼)
938
+ * await client.auth.signInAsGuestMember({ allowOverrideExistingSession: true })
919
939
  * ```
920
940
  */
921
- async signInAsGuestMember() {
941
+ async signInAsGuestMember(opts) {
922
942
  if (this.guestMemberLoginPromise) {
923
943
  return this.guestMemberLoginPromise;
924
944
  }
945
+ if (!opts?.allowOverrideExistingSession && this.hasActiveNonGuestSession()) {
946
+ throw new GuestSessionConflictError();
947
+ }
925
948
  this.guestMemberLoginPromise = this.executeGuestMemberLogin();
926
949
  try {
927
950
  return await this.guestMemberLoginPromise;
@@ -929,6 +952,29 @@ var AuthAPI = class {
929
952
  this.guestMemberLoginPromise = null;
930
953
  }
931
954
  }
955
+ /**
956
+ * 현재 in-memory access token 이 "게스트 토큰이 아닌 다른 세션" 으로 판단되는지 확인.
957
+ *
958
+ * 판별 규칙:
959
+ * - access token 자체가 없으면 false (어떤 세션도 없음)
960
+ * - access token 이 만료됐으면 false (재로그인이 필요한 dead 상태)
961
+ * - persistence='none' 인 경우: 토큰은 메모리에만 존재. 우리는 그 토큰이
962
+ * 게스트인지 회원인지 분별할 메타가 메모리에 없다 → 보수적으로 true 처리.
963
+ * (회원이 가지고 있던 세션을 게스트가 덮어쓰는 게 더 큰 사고이므로
964
+ * false-positive < silent overwrite.)
965
+ * - persistence='localStorage'|'sessionStorage' 인 경우: 저장된 게스트 토큰과
966
+ * 현재 access token 이 일치하면 게스트 세션(false), 다르면 비-게스트(true).
967
+ */
968
+ hasActiveNonGuestSession() {
969
+ const access = this.http.getAccessToken();
970
+ if (!access) return false;
971
+ if (this.isTokenExpired(access)) return false;
972
+ const stored = this.getStoredGuestMemberTokens();
973
+ if (!stored) {
974
+ return true;
975
+ }
976
+ return stored.accessToken !== access;
977
+ }
932
978
  /**
933
979
  * 현재 로그인한 멤버 정보 조회
934
980
  * custom_data를 포함한 멤버 정보를 반환합니다.
@@ -8546,6 +8592,10 @@ var AIAPI = class {
8546
8592
  }
8547
8593
  try {
8548
8594
  const event = JSON.parse(data);
8595
+ if (event.error) {
8596
+ callbacks.onError?.(event.message || event.error || "stream error");
8597
+ return;
8598
+ }
8549
8599
  if (event.type === "sources" && event.sources) {
8550
8600
  callbacks.onSources?.(event.sources);
8551
8601
  continue;
@@ -10825,6 +10875,7 @@ var index_default = ConnectBase;
10825
10875
  GameError,
10826
10876
  GameRoom,
10827
10877
  GameRoomTransport,
10878
+ GuestSessionConflictError,
10828
10879
  NativeAPI,
10829
10880
  SessionManager,
10830
10881
  VideoProcessingError,
package/dist/index.mjs CHANGED
@@ -14,6 +14,15 @@ var AuthError = class extends Error {
14
14
  this.name = "AuthError";
15
15
  }
16
16
  };
17
+ var GuestSessionConflictError = class extends Error {
18
+ constructor() {
19
+ super(
20
+ "signInAsGuestMember refused: an active non-guest session is present in this client. Pass { allowOverrideExistingSession: true } to explicitly replace it, or call signOut() first."
21
+ );
22
+ this.code = "GUEST_SESSION_CONFLICT";
23
+ this.name = "GuestSessionConflictError";
24
+ }
25
+ };
17
26
  var GameError = class extends Error {
18
27
  constructor(init) {
19
28
  super(init.message || init.code || "GameError");
@@ -867,16 +876,29 @@ var AuthAPI = class {
867
876
  * 로컬 스토리지에 저장된 토큰이 있으면 기존 계정으로 재로그인을 시도합니다.
868
877
  * 동시 호출 시 중복 요청 방지 (race condition 방지)
869
878
  *
879
+ * **활성 세션 가드 (3.22.0+)**
880
+ * OAuth/email/username 로 이미 로그인된 세션이 살아있는 채 이 메서드가 호출되면
881
+ * 메인 토큰 슬롯이 silent 로 게스트 토큰으로 덮어써져 사용자가 둔갑되는 회귀가
882
+ * 있었다 (platform-issue 019e6c5d). 이를 막기 위해 활성 비-게스트 세션이 감지되면
883
+ * 기본적으로 `GuestSessionConflictError` 를 던진다. 명시적으로 교체하려면
884
+ * `{ allowOverrideExistingSession: true }` 를 전달하거나 먼저 `signOut()` 을 호출할 것.
885
+ *
870
886
  * @example
871
887
  * ```typescript
872
888
  * const guest = await client.auth.signInAsGuestMember()
873
889
  * await client.realtime.connect({ accessToken: guest.access_token })
890
+ *
891
+ * // 활성 세션을 명시적으로 교체 (예: "게스트로 계속" 버튼)
892
+ * await client.auth.signInAsGuestMember({ allowOverrideExistingSession: true })
874
893
  * ```
875
894
  */
876
- async signInAsGuestMember() {
895
+ async signInAsGuestMember(opts) {
877
896
  if (this.guestMemberLoginPromise) {
878
897
  return this.guestMemberLoginPromise;
879
898
  }
899
+ if (!opts?.allowOverrideExistingSession && this.hasActiveNonGuestSession()) {
900
+ throw new GuestSessionConflictError();
901
+ }
880
902
  this.guestMemberLoginPromise = this.executeGuestMemberLogin();
881
903
  try {
882
904
  return await this.guestMemberLoginPromise;
@@ -884,6 +906,29 @@ var AuthAPI = class {
884
906
  this.guestMemberLoginPromise = null;
885
907
  }
886
908
  }
909
+ /**
910
+ * 현재 in-memory access token 이 "게스트 토큰이 아닌 다른 세션" 으로 판단되는지 확인.
911
+ *
912
+ * 판별 규칙:
913
+ * - access token 자체가 없으면 false (어떤 세션도 없음)
914
+ * - access token 이 만료됐으면 false (재로그인이 필요한 dead 상태)
915
+ * - persistence='none' 인 경우: 토큰은 메모리에만 존재. 우리는 그 토큰이
916
+ * 게스트인지 회원인지 분별할 메타가 메모리에 없다 → 보수적으로 true 처리.
917
+ * (회원이 가지고 있던 세션을 게스트가 덮어쓰는 게 더 큰 사고이므로
918
+ * false-positive < silent overwrite.)
919
+ * - persistence='localStorage'|'sessionStorage' 인 경우: 저장된 게스트 토큰과
920
+ * 현재 access token 이 일치하면 게스트 세션(false), 다르면 비-게스트(true).
921
+ */
922
+ hasActiveNonGuestSession() {
923
+ const access = this.http.getAccessToken();
924
+ if (!access) return false;
925
+ if (this.isTokenExpired(access)) return false;
926
+ const stored = this.getStoredGuestMemberTokens();
927
+ if (!stored) {
928
+ return true;
929
+ }
930
+ return stored.accessToken !== access;
931
+ }
887
932
  /**
888
933
  * 현재 로그인한 멤버 정보 조회
889
934
  * custom_data를 포함한 멤버 정보를 반환합니다.
@@ -8501,6 +8546,10 @@ var AIAPI = class {
8501
8546
  }
8502
8547
  try {
8503
8548
  const event = JSON.parse(data);
8549
+ if (event.error) {
8550
+ callbacks.onError?.(event.message || event.error || "stream error");
8551
+ return;
8552
+ }
8504
8553
  if (event.type === "sources" && event.sources) {
8505
8554
  callbacks.onSources?.(event.sources);
8506
8555
  continue;
@@ -10779,6 +10828,7 @@ export {
10779
10828
  GameError,
10780
10829
  GameRoom,
10781
10830
  GameRoomTransport,
10831
+ GuestSessionConflictError,
10782
10832
  NativeAPI,
10783
10833
  SessionManager,
10784
10834
  VideoProcessingError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "connectbase-client",
3
- "version": "3.26.0",
3
+ "version": "3.27.1",
4
4
  "description": "Connect Base JavaScript/TypeScript SDK for browser and Node.js",
5
5
  "repository": {
6
6
  "type": "git",