@microsoft/omnichannel-chat-sdk 2.0.2 → 2.1.0-main.8f375cf
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 +21 -0
- package/lib/OmnichannelChatSDK.d.ts +46 -0
- package/lib/OmnichannelChatSDK.js +360 -69
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/api/createVoiceVideoCalling.d.ts +1 -0
- package/lib/api/createVoiceVideoCalling.js +29 -17
- package/lib/api/createVoiceVideoCalling.js.map +1 -1
- package/lib/config/settings.d.ts +1 -1
- package/lib/config/settings.js +1 -1
- package/lib/core/ChatSDKConfig.d.ts +6 -0
- package/lib/core/messaging/ACSClient.d.ts +4 -1
- package/lib/core/messaging/ACSClient.js +225 -83
- package/lib/core/messaging/ACSClient.js.map +1 -1
- package/lib/core/messaging/ACSClientConfig.d.ts +3 -0
- package/lib/telemetry/TelemetryEvent.d.ts +4 -0
- package/lib/telemetry/TelemetryEvent.js +4 -0
- package/lib/telemetry/TelemetryEvent.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/chatTokenRenewal.d.ts +44 -0
- package/lib/utils/chatTokenRenewal.js +223 -0
- package/lib/utils/chatTokenRenewal.js.map +1 -0
- package/lib/utils/chatTokenUnauthorizedRecovery.d.ts +64 -0
- package/lib/utils/chatTokenUnauthorizedRecovery.js +293 -0
- package/lib/utils/chatTokenUnauthorizedRecovery.js.map +1 -0
- package/lib/utils/createOmnichannelMessage.js +5 -0
- package/lib/utils/createOmnichannelMessage.js.map +1 -1
- package/lib/utils/messageUpdates.d.ts +10 -0
- package/lib/utils/messageUpdates.js +56 -0
- package/lib/utils/messageUpdates.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ Please make sure you have a chat widget configured before using this package or
|
|
|
35
35
|
- [Send Messages](#send-messages)
|
|
36
36
|
- [On New Message](#on-new-message)
|
|
37
37
|
- [On Streaming Message](#on-streaming-message)
|
|
38
|
+
- [On Chat Token Renewed](#on-chat-token-renewed)
|
|
38
39
|
- [On Typing Event](#on-typing-event)
|
|
39
40
|
- [On Agent End Session](#on-agent-end-session)
|
|
40
41
|
- [Send Typing Event](#send-typing-event)
|
|
@@ -516,6 +517,26 @@ await chatSDK.onStreamingMessage((message) => {
|
|
|
516
517
|
|
|
517
518
|
Calling this method before `startChat()` throws `UninitializedConversation`. If the conversation does not use ACS, this method throws `UnsupportedLiveChatVersion`.
|
|
518
519
|
|
|
520
|
+
### On Chat Token Renewed
|
|
521
|
+
|
|
522
|
+
Subscribes to notifications after the SDK renews the chat token and updates the current live chat context.
|
|
523
|
+
If your application caches this context for page refresh or reconnect, save the updated context in the callback
|
|
524
|
+
so subsequent restores use the renewed credentials.
|
|
525
|
+
|
|
526
|
+
Register before `startChat()` to capture renewals during startup, including when restoring a saved chat.
|
|
527
|
+
|
|
528
|
+
```ts
|
|
529
|
+
const unsubscribe = chatSDK.onChatTokenRenewed(async () => {
|
|
530
|
+
const liveChatContext = await chatSDK.getCurrentLiveChatContext();
|
|
531
|
+
cache.saveChatContext(liveChatContext); // Custom logic to save chat context to cache
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
await chatSDK.startChat();
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
The listener remains registered across chats on the same SDK instance; call `unsubscribe()` during cleanup.
|
|
538
|
+
Token renewal works without a subscription.
|
|
539
|
+
|
|
519
540
|
### On Typing Event
|
|
520
541
|
|
|
521
542
|
It subscribes to an agent typing event.
|
|
@@ -57,6 +57,8 @@ declare class OmnichannelChatSDK {
|
|
|
57
57
|
private coreServicesOrgUrl;
|
|
58
58
|
private dynamicsLocationCode;
|
|
59
59
|
private chatToken;
|
|
60
|
+
private chatTokenUnauthorizedRecovery;
|
|
61
|
+
private chatTokenRenewedListeners;
|
|
60
62
|
private liveChatConfig;
|
|
61
63
|
private widgetSnippetBaseUrl;
|
|
62
64
|
private liveChatVersion;
|
|
@@ -77,6 +79,7 @@ declare class OmnichannelChatSDK {
|
|
|
77
79
|
private isPersistentChat;
|
|
78
80
|
private isChatReconnect;
|
|
79
81
|
private reconnectId;
|
|
82
|
+
private endedChatSessionKey;
|
|
80
83
|
private refreshTokenTimer;
|
|
81
84
|
private AMSClientLoadCurrentState;
|
|
82
85
|
private isMaskingDisabled;
|
|
@@ -155,6 +158,15 @@ declare class OmnichannelChatSDK {
|
|
|
155
158
|
private waitForMessageTags;
|
|
156
159
|
private waitForSurveyStart;
|
|
157
160
|
private waitForConversationalSurveyEnd;
|
|
161
|
+
/**
|
|
162
|
+
* Subscribes to usable chat token renewals after the current SDK context has been updated.
|
|
163
|
+
* No token or other payload is passed. Read getCurrentLiveChatContext() to persist the updated context.
|
|
164
|
+
* Returns an idempotent unsubscribe function. Listener failures never affect renewal.
|
|
165
|
+
* Subscriptions belong to this SDK instance and survive endChat()/startChat().
|
|
166
|
+
* Subscribe before startChat() to observe restoration renewals; past notifications are not replayed.
|
|
167
|
+
* Unsubscribe on host teardown or before replacing a per-chat subscription.
|
|
168
|
+
*/
|
|
169
|
+
onChatTokenRenewed(listener: () => void): () => void;
|
|
158
170
|
getCurrentLiveChatContext(): Promise<GetCurrentLiveChatContextResponse>;
|
|
159
171
|
getConversationDetails(optionalParams?: GetConversationDetailsOptionalParams): Promise<LiveWorkItemDetails>;
|
|
160
172
|
/**
|
|
@@ -165,6 +177,31 @@ declare class OmnichannelChatSDK {
|
|
|
165
177
|
getLiveChatConfig(optionalParams?: GetLiveChatConfigOptionalParams): Promise<ChatConfig>;
|
|
166
178
|
getChatToken(cached?: boolean, optionalParams?: GetChatTokenOptionalParams): Promise<IChatToken>;
|
|
167
179
|
setChatToken(chatToken: FetchChatTokenResponse): void;
|
|
180
|
+
/**
|
|
181
|
+
* Creates the ACS token refresher used to renew the chat token before it expires. Returns undefined, which keeps
|
|
182
|
+
* the existing behavior, unless renewal is enabled in the chat config, not disabled in the SDK config and
|
|
183
|
+
* supported by the installed OCSDK. The refresher never throws and falls back to the current token on failure.
|
|
184
|
+
*/
|
|
185
|
+
private createChatTokenRefresher;
|
|
186
|
+
private notifyChatTokenRenewed;
|
|
187
|
+
/**
|
|
188
|
+
* Gives the renewed chat token to the attachment client, which keeps the token it was initialized with and uses
|
|
189
|
+
* it for every upload and download. Runs in the background and never throws: on failure, attachments keep using
|
|
190
|
+
* the previous token as they did before renewal existed.
|
|
191
|
+
*/
|
|
192
|
+
private refreshAttachmentClientToken;
|
|
193
|
+
/**
|
|
194
|
+
* Creates the recovery for chat requests that fail with 401 while the chat token has not
|
|
195
|
+
* expired. Returns null, which keeps the existing behavior, unless chat token renewal is enabled and recovery is
|
|
196
|
+
* not disabled in the SDK config.
|
|
197
|
+
*/
|
|
198
|
+
private createChatTokenUnauthorizedRecovery;
|
|
199
|
+
/**
|
|
200
|
+
* Returns the token of the authenticated user to renew the chat token with, refreshed from the auth token
|
|
201
|
+
* provider when possible because the token used to start the chat may have expired. Returns undefined for
|
|
202
|
+
* unauthenticated chats.
|
|
203
|
+
*/
|
|
204
|
+
private getAuthenticatedUserTokenForChatTokenRenewal;
|
|
168
205
|
getCallingToken(): Promise<string>;
|
|
169
206
|
private recordMessages;
|
|
170
207
|
getMessages(): Promise<GetMessagesResponse>;
|
|
@@ -208,6 +245,15 @@ declare class OmnichannelChatSDK {
|
|
|
208
245
|
downloadFileAttachment(fileMetadata: FileMetadata | IFileMetadata): Promise<Blob>;
|
|
209
246
|
emailLiveChatTranscript(body: ChatTranscriptBody, optionalParams?: EmailLiveChatTranscriptOptionaParams): Promise<void>;
|
|
210
247
|
getLiveChatTranscript(optionalParams?: GetLiveChatTranscriptOptionalParams): Promise<GetLiveChatTranscriptResponse>;
|
|
248
|
+
/**
|
|
249
|
+
* Returns the ended chat's session key when the call targets that chat, or null.
|
|
250
|
+
*/
|
|
251
|
+
private getEndedChatSessionKey;
|
|
252
|
+
/**
|
|
253
|
+
* Sends the session key on one OCSDK request without leaving it on the shared client. OCSDK copies the
|
|
254
|
+
* key into the request headers before its first await, so the previous key is restored before the HTTP wait.
|
|
255
|
+
*/
|
|
256
|
+
private withRequestSessionKey;
|
|
211
257
|
createChatAdapter(optionalParams?: ChatAdapterOptionalParams): Promise<ChatAdapter>;
|
|
212
258
|
isVoiceVideoCallingEnabled(): boolean;
|
|
213
259
|
getVoiceVideoCalling(voiceVideoCallingOptionalParams?: VoiceVideoCallingOptionalParams): Promise<GetVoiceVideoCallingResponse>;
|