@ujet/websdk-headless 6.14.0 → 6.17.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/dist/index.d.ts CHANGED
@@ -28,6 +28,44 @@ declare enum ChannelType {
28
28
  VOICEMAIL = "voicemail"
29
29
  }
30
30
 
31
+ /**
32
+ * Chat wire-protocol vocabulary shared by every provider. Values are the
33
+ * strings on the wire — the server and the agent app match them verbatim.
34
+ */
35
+ declare enum MessageType {
36
+ TEXT = "text",
37
+ NOTI = "noti",
38
+ SERVER_MESSAGE = "server_message",
39
+ TYPING = "typing",
40
+ PREVIEW = "preview",
41
+ TRANSLATION_UPDATE = "translation_update"
42
+ }
43
+ /** `event` values carried by a `noti` message. */
44
+ declare enum NotiEvent {
45
+ MEMBER_JOINED = "memberJoined",
46
+ MEMBER_LEFT = "memberLeft",
47
+ CHAT_ENDED = "chatEnded",
48
+ CHAT_DISMISSED = "chatDismissed",
49
+ TASK_VA_STARTED = "taskVaStarted",
50
+ TASK_VA_FINISHED = "taskVaFinished",
51
+ TASK_VA_FAILED = "taskVaFailed",
52
+ ESCALATION_STARTED = "escalationStarted",
53
+ ESCALATION_ACCEPTED = "escalationAccepted",
54
+ ESCALATION_FAILED = "escalationFailed",
55
+ CHECK_IN_REQUIRED = "checkInRequired",
56
+ CHECK_IN_TIMED_OUT = "checkInTimedOut",
57
+ COBROWSE_REQUESTED_FROM_AGENT = "cobrowseRequestedFromAgent",
58
+ COBROWSE_REQUESTED_FROM_END_USER = "cobrowseRequestedFromEndUser"
59
+ }
60
+ /** Participant kinds — the prefix of a `<type>-<id>` identity and the `$userType` of a message. */
61
+ declare enum UserType {
62
+ END_USER = "end_user",
63
+ USER = "user",
64
+ VIRTUAL_AGENT = "virtual_agent",
65
+ SYSTEM = "system"
66
+ }
67
+ declare function toIdentity(userType: UserType, id: number | string): string;
68
+
31
69
  interface LanguageOption {
32
70
  lang: string;
33
71
  name: string;
@@ -126,6 +164,10 @@ interface ChatResponse {
126
164
  all_virtual_agents: VirtualAgent[];
127
165
  redaction_enabled: boolean;
128
166
  agent_incoming_ha_enabled: boolean;
167
+ end_user?: {
168
+ id: number;
169
+ identifier?: string | null;
170
+ };
129
171
  post_session_required?: boolean;
130
172
  post_session_opt_in_required?: boolean;
131
173
  post_session_transfer_status?: string;
@@ -199,6 +241,8 @@ interface MessageResponse {
199
241
  title?: string;
200
242
  type: string;
201
243
  unredacted?: string;
244
+ client_message_id?: string | undefined;
245
+ redaction_ref?: number | undefined;
202
246
  signature?: string;
203
247
  form?: {
204
248
  id: number;
@@ -214,6 +258,13 @@ interface MessageResponse {
214
258
  reason?: string;
215
259
  [key: string]: unknown;
216
260
  }
261
+ /** GET /chats/:id/messages/:redaction_ref/original — only the requester's own messages resolve. */
262
+ interface ChatMessageOriginalResponse {
263
+ redaction_ref: number;
264
+ content: string;
265
+ type: string;
266
+ media_id?: number | undefined;
267
+ }
217
268
  interface PdfStatusResponse {
218
269
  body?: File;
219
270
  failed_reason?: string;
@@ -490,6 +541,7 @@ interface ChatMessageRequest {
490
541
  message: {
491
542
  content: string;
492
543
  timestamp: string;
544
+ client_message_id?: string | undefined;
493
545
  };
494
546
  }
495
547
  interface CheckInVisibilityStateRequest {
@@ -708,6 +760,8 @@ interface ChatHooks {
708
760
  leaveChat?: () => Promise<void>;
709
761
  leaveChatBeacon?: () => void;
710
762
  isRiskFlagEnabled?: (flagName: string) => boolean;
763
+ /** Ownership-checked lookup of a redacted message's original; rejects with `{ status }` on HTTP errors. */
764
+ fetchMessageOriginal?: (redactionRef: number) => Promise<ChatMessageOriginalResponse>;
711
765
  }
712
766
  declare class Chat {
713
767
  private provider;
@@ -720,6 +774,11 @@ declare class Chat {
720
774
  private events;
721
775
  private cachedFiles;
722
776
  private hooks;
777
+ private originals;
778
+ private cacheOwner;
779
+ private restoredMessages;
780
+ private nextTrackedSweepAt;
781
+ private destroying;
723
782
  private leaveSent;
724
783
  private beaconAttempted;
725
784
  constructor(state: ChatResponse, issueChatToken: IssueChatTokenMethod, hooks?: ChatHooks, providerContext?: ProviderContext);
@@ -737,6 +796,16 @@ declare class Chat {
737
796
  human: HumanAgent[];
738
797
  };
739
798
  get userIdentity(): string;
799
+ /**
800
+ * The end user's participant id, from the chat payload (both providers) and
801
+ * the provider token identity (`end_user-<id>`). Either alone is enough;
802
+ * when both are known they must agree. null when neither is known or they
803
+ * disagree — ownership then cannot be established and nothing is restored.
804
+ */
805
+ get ownUserId(): number | null;
806
+ private get ownerConflict();
807
+ private get payloadOwnerId();
808
+ private get providerOwnerId();
740
809
  get status(): string;
741
810
  get postSessionStatus(): string;
742
811
  get statusText(): string;
@@ -769,6 +838,38 @@ declare class Chat {
769
838
  sendMessage(message: MessageRequest, file?: File): Promise<number>;
770
839
  preview(text: string | undefined): Promise<void>;
771
840
  fetchMessages(): Promise<MessageResponse[]>;
841
+ /**
842
+ * Re-binds the cache to the live owner and returns the owner to judge
843
+ * messages by. On a change — payload end_user, provider identity, or a move
844
+ * between the two — everything remembered for the previous owner is dropped
845
+ * and every original already shown is taken back, before any of it can be
846
+ * read for the new one. Metadata that is merely absent (an update without
847
+ * end_user on a provider that carries no identity) is not a change: the
848
+ * established owner stands until a different one, or a conflict, appears.
849
+ */
850
+ private syncCacheOwner;
851
+ private rebindCacheOwner;
852
+ private revokeOriginals;
853
+ private trackRestored;
854
+ private localOriginalCacheEnabled;
855
+ /**
856
+ * Joins the original onto `message.unredacted` for the end user's own
857
+ * redacted text: local cache → in-band `unredacted` → (returns true) a
858
+ * redaction_ref lookup. Another end user's in-band original is dropped so
859
+ * the userType-only render check cannot expose it. Agent and system
860
+ * messages are left alone.
861
+ *
862
+ * @returns whether a store lookup is still needed for this message
863
+ */
864
+ private restoreOwnOriginal;
865
+ /**
866
+ * Puts an original onto `message.unredacted` — through the same sanitizer
867
+ * the masked content went through, since the widget renders it as HTML —
868
+ * and tracks the message for revocation. False when there was nothing
869
+ * usable to show; a rejected original is removed rather than kept raw.
870
+ */
871
+ private applyOriginal;
872
+ private lookupOwnOriginal;
772
873
  startTyping(): void;
773
874
  stopTyping(): void;
774
875
  saveMedia(index: AttachmentKey, file: File): void;
@@ -1434,4 +1535,4 @@ declare const COBROWSE_EVENTS: {
1434
1535
  };
1435
1536
  type CobrowseEvent = (typeof COBROWSE_EVENTS)[keyof typeof COBROWSE_EVENTS];
1436
1537
 
1437
- export { AnotherTabVoiceCallError, type AttachmentKey, BaseProvider, BaseVoiceProvider, COBROWSE_EVENTS, type CallApiResponse, CallInProgressError, type CallRequest, type CallResponse, ChannelType, Chat, type ChatDeflectionResponse, type ChatDocumentItem, type ChatEndUserEventRequest, ChatEndedError, type ChatHistoryItem, type ChatHistoryResponse, type ChatMessageRequest, type ChatMessageResponse, type ChatRequest, type ChatResponse, type ChatSurveyResponse, type ChatTaskMessageResponse, type CheckInModalStateRequest, type CheckInResponse, CheckInStatus, type CheckInVisibilityStateRequest, Client, type ClientEvent, type ClientOption, type CobrowseEvent, type CobrowseMessages, type CobrowseOption, type CobrowseRequest, type CompanyResponse, type ConnectCallback, type ConnectOption, type ConnectRequest, type ConnectResult, type ConnectionQualityLevel, type ConnectionQualityWarning, type CustomFormPayload, ENVIRONMENT, type EmailRequest, type EmailResponse, type EscalateRequest, type EventHandler, EventManager, type FeatureFlagsResponse, FeatureNotEnabledError, type FileTypeItem, type FormData, type GenerateTranscriptResponse, type GetServerMessage, type GetTimeSlotsRequest, type HumanAgent, InboundDisabledError, type IssueChatTokenMethod, type IssueVoiceTokenMethod, type LanguageOption, type LogData, type LogHistoryData, Logger, type LoggerHandler, type MediaIndex, type MediaRef, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MenusRoutingInputs, type MessageRequest, type MessageResponse, MicPermissionDeniedError, type MicPermissionState, NoActiveVoiceCallError, OPTIONS, OperationHoursError, type PdfStatusResponse, PostSessionStatus, type ProviderContext, ProviderError, ProviderType, type QuestionItem, RISK_FLAG_EVENTS, type RateRequest, type RecordingOption, type RecordingPermission, type RefusedBy, type RequestMethod, type RequestReturn, type ServerAuthResponse, type ServerVoiceCallStatus, SmartActionError, type SmartActionMediaType, type SmartActionResponse, type SmartActionType, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, type UjetConversationHistoryQuery, type UjetConversationHistoryResponse, type UjetConversationMessageItem, UnauthorizedError, UnknownVoiceError, type UserProfile, VERSION, VOICE_EVENTS, type VirtualAgent, VoiceCall, VoiceCallError, type VoiceCallRequest, type VoiceCallResponse, type VoiceCallStatus, type VoiceCobrowseRequestedEvent, type VoiceCobrowseResolvedEvent, type VoiceConnectionQualityEvent, type VoiceErrorCode, type VoiceErrorEvent, type VoiceFeedbackType, type VoiceProviderConstructor, type VoiceProviderMessage, type VoiceProviderMessageType, type VoiceRecordingPermissionRequiredEvent, type VoiceSmartActionRequestedEvent, type VoiceSmartActionResolvedEvent, type VoiceStatusChangedEvent, type WaitTimeResponse, addProviderType, addVoiceProviderType, getErrorMessage, getErrorStatus, getVoiceProviderType, hasErrorCode, isAfterHoursError, isMobilePlatform };
1538
+ export { AnotherTabVoiceCallError, type AttachmentKey, BaseProvider, BaseVoiceProvider, COBROWSE_EVENTS, type CallApiResponse, CallInProgressError, type CallRequest, type CallResponse, ChannelType, Chat, type ChatDeflectionResponse, type ChatDocumentItem, type ChatEndUserEventRequest, ChatEndedError, type ChatHistoryItem, type ChatHistoryResponse, type ChatMessageOriginalResponse, type ChatMessageRequest, type ChatMessageResponse, type ChatRequest, type ChatResponse, type ChatSurveyResponse, type ChatTaskMessageResponse, type CheckInModalStateRequest, type CheckInResponse, CheckInStatus, type CheckInVisibilityStateRequest, Client, type ClientEvent, type ClientOption, type CobrowseEvent, type CobrowseMessages, type CobrowseOption, type CobrowseRequest, type CompanyResponse, type ConnectCallback, type ConnectOption, type ConnectRequest, type ConnectResult, type ConnectionQualityLevel, type ConnectionQualityWarning, type CustomFormPayload, ENVIRONMENT, type EmailRequest, type EmailResponse, type EscalateRequest, type EventHandler, EventManager, type FeatureFlagsResponse, FeatureNotEnabledError, type FileTypeItem, type FormData, type GenerateTranscriptResponse, type GetServerMessage, type GetTimeSlotsRequest, type HumanAgent, InboundDisabledError, type IssueChatTokenMethod, type IssueVoiceTokenMethod, type LanguageOption, type LogData, type LogHistoryData, Logger, type LoggerHandler, type MediaIndex, type MediaRef, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MenusRoutingInputs, type MessageRequest, type MessageResponse, MessageType, MicPermissionDeniedError, type MicPermissionState, NoActiveVoiceCallError, NotiEvent, OPTIONS, OperationHoursError, type PdfStatusResponse, PostSessionStatus, type ProviderContext, ProviderError, ProviderType, type QuestionItem, RISK_FLAG_EVENTS, type RateRequest, type RecordingOption, type RecordingPermission, type RefusedBy, type RequestMethod, type RequestReturn, type ServerAuthResponse, type ServerVoiceCallStatus, SmartActionError, type SmartActionMediaType, type SmartActionResponse, type SmartActionType, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, type UjetConversationHistoryQuery, type UjetConversationHistoryResponse, type UjetConversationMessageItem, UnauthorizedError, UnknownVoiceError, type UserProfile, UserType, VERSION, VOICE_EVENTS, type VirtualAgent, VoiceCall, VoiceCallError, type VoiceCallRequest, type VoiceCallResponse, type VoiceCallStatus, type VoiceCobrowseRequestedEvent, type VoiceCobrowseResolvedEvent, type VoiceConnectionQualityEvent, type VoiceErrorCode, type VoiceErrorEvent, type VoiceFeedbackType, type VoiceProviderConstructor, type VoiceProviderMessage, type VoiceProviderMessageType, type VoiceRecordingPermissionRequiredEvent, type VoiceSmartActionRequestedEvent, type VoiceSmartActionResolvedEvent, type VoiceStatusChangedEvent, type WaitTimeResponse, addProviderType, addVoiceProviderType, getErrorMessage, getErrorStatus, getVoiceProviderType, hasErrorCode, isAfterHoursError, isMobilePlatform, toIdentity };