@microsoft/omnichannel-chat-widget 1.7.8-main.2e1cc2b → 1.7.8-main.9e74278

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.
@@ -149,6 +149,7 @@ class FacadeChatSDK {
149
149
  }
150
150
  }
151
151
  async tokenRing() {
152
+ var _this$chatSDK$chatSDK;
152
153
  if (this.disableReauthentication === true) {
153
154
  // facade feature is disabled, so we are bypassing the re authentication and let it fail.
154
155
  return {
@@ -176,7 +177,7 @@ class FacadeChatSDK {
176
177
  message: "Token is valid"
177
178
  };
178
179
  }
179
- if (this.getAuthToken === undefined) {
180
+ if (this.getAuthToken === undefined && ((_this$chatSDK$chatSDK = this.chatSDK.chatSDKConfig) === null || _this$chatSDK$chatSDK === void 0 ? void 0 : _this$chatSDK$chatSDK.getAuthToken) === undefined) {
180
181
  _TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
181
182
  Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
182
183
  Description: "GetAuthToken function is not present",
@@ -18,6 +18,7 @@ const getAuthClientFunction = chatConfig => {
18
18
  };
19
19
  exports.getAuthClientFunction = getAuthClientFunction;
20
20
  const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
21
+ var _chatSDK$chatSDKConfi;
21
22
  const authClientFunction = getAuthClientFunction(chatConfig);
22
23
  if (getAuthToken && authClientFunction) {
23
24
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -41,6 +42,20 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
41
42
  });
42
43
  throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
43
44
  }
45
+ } else if (chatSDK !== null && chatSDK !== void 0 && (_chatSDK$chatSDKConfi = chatSDK.chatSDKConfig) !== null && _chatSDK$chatSDKConfi !== void 0 && _chatSDK$chatSDKConfi.getAuthToken) {
46
+ var _chatSDK$chatSDKConfi2;
47
+ const token = await ((_chatSDK$chatSDKConfi2 = chatSDK.chatSDKConfig) === null || _chatSDK$chatSDKConfi2 === void 0 ? void 0 : _chatSDK$chatSDKConfi2.getAuthToken());
48
+ if ((0, _utils.isNullOrEmptyString)(token)) {
49
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
50
+ Event: _TelemetryConstants.TelemetryEvent.ReceivedNullOrEmptyToken,
51
+ Description: "getAuthToken in chat SDK returns empty string"
52
+ });
53
+ throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
54
+ }
55
+ return {
56
+ "result": true,
57
+ token
58
+ };
44
59
  }
45
60
  return {
46
61
  "result": false,
@@ -143,6 +143,7 @@ export class FacadeChatSDK {
143
143
  }
144
144
  }
145
145
  async tokenRing() {
146
+ var _this$chatSDK$chatSDK;
146
147
  if (this.disableReauthentication === true) {
147
148
  // facade feature is disabled, so we are bypassing the re authentication and let it fail.
148
149
  return {
@@ -170,7 +171,7 @@ export class FacadeChatSDK {
170
171
  message: "Token is valid"
171
172
  };
172
173
  }
173
- if (this.getAuthToken === undefined) {
174
+ if (this.getAuthToken === undefined && ((_this$chatSDK$chatSDK = this.chatSDK.chatSDKConfig) === null || _this$chatSDK$chatSDK === void 0 ? void 0 : _this$chatSDK$chatSDK.getAuthToken) === undefined) {
174
175
  TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
175
176
  Event: TelemetryEvent.NewTokenFailed,
176
177
  Description: "GetAuthToken function is not present",
@@ -11,6 +11,7 @@ const getAuthClientFunction = chatConfig => {
11
11
  return authClientFunction;
12
12
  };
13
13
  const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
14
+ var _chatSDK$chatSDKConfi;
14
15
  const authClientFunction = getAuthClientFunction(chatConfig);
15
16
  if (getAuthToken && authClientFunction) {
16
17
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
@@ -34,6 +35,20 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
34
35
  });
35
36
  throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
36
37
  }
38
+ } else if (chatSDK !== null && chatSDK !== void 0 && (_chatSDK$chatSDKConfi = chatSDK.chatSDKConfig) !== null && _chatSDK$chatSDKConfi !== void 0 && _chatSDK$chatSDKConfi.getAuthToken) {
39
+ var _chatSDK$chatSDKConfi2;
40
+ const token = await ((_chatSDK$chatSDKConfi2 = chatSDK.chatSDKConfig) === null || _chatSDK$chatSDKConfi2 === void 0 ? void 0 : _chatSDK$chatSDKConfi2.getAuthToken());
41
+ if (isNullOrEmptyString(token)) {
42
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
43
+ Event: TelemetryEvent.ReceivedNullOrEmptyToken,
44
+ Description: "getAuthToken in chat SDK returns empty string"
45
+ });
46
+ throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
47
+ }
48
+ return {
49
+ "result": true,
50
+ token
51
+ };
37
52
  }
38
53
  return {
39
54
  "result": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.7.8-main.2e1cc2b",
3
+ "version": "1.7.8-main.9e74278",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",