isometrik-plugin-chat-sdk 1.0.1 → 1.0.2

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.
Files changed (38) hide show
  1. package/dist/cjs/{MessageSearch-f5b72462.js → MessageSearch-a73ca677.js} +82 -11
  2. package/dist/cjs/MessageSearch-a73ca677.js.map +1 -0
  3. package/dist/cjs/{WebChat-2329244b.js → WebChat-11c06cb9.js} +428 -37
  4. package/dist/cjs/WebChat-11c06cb9.js.map +1 -0
  5. package/dist/cjs/audio-bubble_8.cjs.entry.js +1 -1
  6. package/dist/cjs/chat-app.cjs.entry.js +2 -2
  7. package/dist/cjs/theme-provider_2.cjs.entry.js +2 -2
  8. package/dist/collection/api/social-accounts.js +77 -9
  9. package/dist/collection/components/my-component/web-chat/WebChat.js +19 -14
  10. package/dist/collection/components/my-component/web-chat/WebChat.js.map +1 -1
  11. package/dist/collection/stories/Components/InstagramAccounts/InstagramAccountsPanel.js +412 -22
  12. package/dist/esm/{MessageSearch-4010486c.js → MessageSearch-69b3a0f3.js} +79 -11
  13. package/dist/esm/MessageSearch-69b3a0f3.js.map +1 -0
  14. package/dist/esm/{WebChat-95518d72.js → WebChat-372df148.js} +428 -37
  15. package/dist/esm/WebChat-372df148.js.map +1 -0
  16. package/dist/esm/audio-bubble_8.entry.js +2 -2
  17. package/dist/esm/chat-app.entry.js +2 -2
  18. package/dist/esm/theme-provider_2.entry.js +2 -2
  19. package/dist/isometrik-webchat/isometrik-webchat.esm.js +1 -1
  20. package/dist/isometrik-webchat/{p-d7e335cb.entry.js → p-56fbdbc3.entry.js} +2 -2
  21. package/dist/isometrik-webchat/{p-35f143c9.entry.js → p-8456ee94.entry.js} +2 -2
  22. package/dist/isometrik-webchat/{p-55355714.js → p-9058d82c.js} +17 -17
  23. package/dist/isometrik-webchat/p-9058d82c.js.map +1 -0
  24. package/dist/isometrik-webchat/p-9588b7ec.js +780 -0
  25. package/dist/isometrik-webchat/p-9588b7ec.js.map +1 -0
  26. package/dist/isometrik-webchat/{p-675c105e.entry.js → p-e66e5e61.entry.js} +2 -2
  27. package/package.json +1 -1
  28. package/readme.md +5 -5
  29. package/dist/cjs/MessageSearch-f5b72462.js.map +0 -1
  30. package/dist/cjs/WebChat-2329244b.js.map +0 -1
  31. package/dist/esm/MessageSearch-4010486c.js.map +0 -1
  32. package/dist/esm/WebChat-95518d72.js.map +0 -1
  33. package/dist/isometrik-webchat/p-55355714.js.map +0 -1
  34. package/dist/isometrik-webchat/p-e954c29f.js +0 -591
  35. package/dist/isometrik-webchat/p-e954c29f.js.map +0 -1
  36. /package/dist/isometrik-webchat/{p-d7e335cb.entry.js.map → p-56fbdbc3.entry.js.map} +0 -0
  37. /package/dist/isometrik-webchat/{p-35f143c9.entry.js.map → p-8456ee94.entry.js.map} +0 -0
  38. /package/dist/isometrik-webchat/{p-675c105e.entry.js.map → p-e66e5e61.entry.js.map} +0 -0
@@ -6,7 +6,7 @@ const index = require('./index-9afe62b6.js');
6
6
  const imagePlaceholder = require('./imagePlaceholder-030cc566.js');
7
7
  const dialogDrawer = require('./dialog-drawer-9d04911c.js');
8
8
  const Image$1 = require('./Image-67c52acd.js');
9
- const MessageSearch = require('./MessageSearch-f5b72462.js');
9
+ const MessageSearch = require('./MessageSearch-a73ca677.js');
10
10
  const Text = require('./Text-fedf6eab.js');
11
11
  const chatAssets = require('./chat-assets-6ab1faa6.js');
12
12
  const toastHelper = require('./toast-helper-defae4a5.js');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-9afe62b6.js');
6
- require('./WebChat-2329244b.js');
6
+ require('./WebChat-11c06cb9.js');
7
7
  require('./Image-67c52acd.js');
8
8
  require('./chat-creds-7ddd5f40.js');
9
9
  require('./dialog-drawer-9d04911c.js');
@@ -11,7 +11,7 @@ require('./content-eca5336c.js');
11
11
  require('./Text-fedf6eab.js');
12
12
  require('./group-members-a60fb1cb.js');
13
13
  require('./toast-helper-defae4a5.js');
14
- require('./MessageSearch-f5b72462.js');
14
+ require('./MessageSearch-a73ca677.js');
15
15
  require('./BlockChatList-720a703e.js');
16
16
  require('./imagePlaceholder-030cc566.js');
17
17
  require('./taguser-aca04ed9.js');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-9afe62b6.js');
6
- const WebChat = require('./WebChat-2329244b.js');
6
+ const WebChat = require('./WebChat-11c06cb9.js');
7
7
  require('./Image-67c52acd.js');
8
8
  require('./chat-creds-7ddd5f40.js');
9
9
  require('./dialog-drawer-9d04911c.js');
@@ -11,7 +11,7 @@ require('./content-eca5336c.js');
11
11
  require('./Text-fedf6eab.js');
12
12
  require('./group-members-a60fb1cb.js');
13
13
  require('./toast-helper-defae4a5.js');
14
- require('./MessageSearch-f5b72462.js');
14
+ require('./MessageSearch-a73ca677.js');
15
15
  require('./BlockChatList-720a703e.js');
16
16
  require('./imagePlaceholder-030cc566.js');
17
17
  require('./taguser-aca04ed9.js');
@@ -149,7 +149,7 @@ export const openSocialAuthPopup = (authUrl) =>
149
149
  }, 400);
150
150
  });
151
151
 
152
- /** POST /chat/social/connect */
152
+ /** POST /chat/social/connect — Instagram OAuth (authUrl) or LinkedIn credentials */
153
153
  export const connectSocialAccount = async ({
154
154
  baseUrl,
155
155
  appSecret,
@@ -157,24 +157,86 @@ export const connectSocialAccount = async ({
157
157
  platform = 'instagram',
158
158
  redirectUrl,
159
159
  loginMethod = 'instagram_login',
160
+ username,
161
+ password,
162
+ agentUserId,
160
163
  } = {}) => {
161
164
  const creds = getCreds({ baseUrl, appSecret, licenseKey });
165
+ const body =
166
+ platform === 'linkedin'
167
+ ? {
168
+ platform: 'linkedin',
169
+ username,
170
+ password,
171
+ agentUserId: agentUserId || CHAT_CREDS.isometrikUserId,
172
+ }
173
+ : {
174
+ platform,
175
+ redirectUrl: redirectUrl || getSocialRedirectUrl(),
176
+ loginMethod,
177
+ };
178
+
162
179
  const response = await fetch(`${creds.baseUrl}/chat/social/connect`, {
180
+ method: 'POST',
181
+ headers: getHeaders(creds.appSecret, creds.licenseKey),
182
+ body: JSON.stringify(body),
183
+ });
184
+ const data = await response.json();
185
+ if (!response.ok) {
186
+ throw new Error(data.message || 'Failed to connect social account');
187
+ }
188
+ return data;
189
+ };
190
+
191
+ /** POST /chat/social/connect/checkpoint — LinkedIn OTP / 2FA */
192
+ export const submitSocialConnectCheckpoint = async ({
193
+ baseUrl,
194
+ appSecret,
195
+ licenseKey,
196
+ platform = 'linkedin',
197
+ accountId,
198
+ code,
199
+ agentUserId,
200
+ } = {}) => {
201
+ const creds = getCreds({ baseUrl, appSecret, licenseKey });
202
+ const response = await fetch(`${creds.baseUrl}/chat/social/connect/checkpoint`, {
163
203
  method: 'POST',
164
204
  headers: getHeaders(creds.appSecret, creds.licenseKey),
165
205
  body: JSON.stringify({
166
206
  platform,
167
- redirectUrl: redirectUrl || getSocialRedirectUrl(),
168
- loginMethod,
207
+ accountId,
208
+ code,
209
+ agentUserId: agentUserId || CHAT_CREDS.isometrikUserId,
169
210
  }),
170
211
  });
171
212
  const data = await response.json();
172
213
  if (!response.ok) {
173
- throw new Error(data.message || 'Failed to connect social account');
214
+ throw new Error(data.message || 'Failed to complete social checkpoint');
174
215
  }
175
216
  return data;
176
217
  };
177
218
 
219
+ /** True when connect response still needs OTP / 2FA. */
220
+ export const isSocialCheckpointRequired = (data = {}) => {
221
+ if (!data || typeof data !== 'object') return false;
222
+ const status = String(data.status || data.checkpointStatus || '').toLowerCase();
223
+ if (status.includes('checkpoint') || status === 'pending' || status === 'otp_required') {
224
+ return true;
225
+ }
226
+ if (data.checkpoint || data.checkpointType || data.checkpointRequired) return true;
227
+ if (data.object === 'Checkpoint' || data.object === 'checkpoint') return true;
228
+ return false;
229
+ };
230
+
231
+ export const getSocialAccountIdFromConnect = (data = {}) =>
232
+ data?.accountId ||
233
+ data?.zernioAccountId ||
234
+ data?.unipileAccountId ||
235
+ data?.checkpoint?.account_id ||
236
+ data?.checkpoint?.accountId ||
237
+ data?.data?.accountId ||
238
+ '';
239
+
178
240
  /** POST /chat/social/connect/callback — zernioAccountId from GET /chat/social/accounts */
179
241
  export const connectSocialAccountCallback = async ({
180
242
  baseUrl,
@@ -218,24 +280,30 @@ export const connectSocialAccountCallback = async ({
218
280
  return data;
219
281
  };
220
282
 
221
- /** True when at least one Instagram account is actively linked. */
222
- export const hasConnectedInstagramAccounts = (accounts = []) =>
283
+ /** True when at least one social account is actively linked. */
284
+ export const hasConnectedSocialAccounts = (accounts = []) =>
223
285
  (accounts || []).some(
224
286
  (account) =>
225
287
  account &&
226
- (account.zernioAccountId || account.accountId) &&
288
+ (account.zernioAccountId || account.accountId || account.unipileAccountId) &&
227
289
  account.status === 'connected'
228
290
  );
229
291
 
230
292
  /** Only accounts that are actively connected (API keeps disconnected rows). */
231
- export const getConnectedInstagramAccounts = (accounts = []) =>
293
+ export const getConnectedSocialAccounts = (accounts = []) =>
232
294
  (accounts || []).filter(
233
295
  (account) =>
234
296
  account &&
235
- (account.zernioAccountId || account.accountId) &&
297
+ (account.zernioAccountId || account.accountId || account.unipileAccountId) &&
236
298
  account.status === 'connected'
237
299
  );
238
300
 
301
+ /** @deprecated use hasConnectedSocialAccounts */
302
+ export const hasConnectedInstagramAccounts = hasConnectedSocialAccounts;
303
+
304
+ /** @deprecated use getConnectedSocialAccounts */
305
+ export const getConnectedInstagramAccounts = getConnectedSocialAccounts;
306
+
239
307
  /** GET /chat/social/accounts?platform=... */
240
308
  export const getSocialAccounts = async ({
241
309
  baseUrl,
@@ -121,8 +121,7 @@ export class WebChat {
121
121
  window.history.replaceState({}, '', url);
122
122
  }
123
123
  };
124
- this.applyInstagramAccounts = (accounts = [], options = {}) => {
125
- const connected = hasConnectedInstagramAccounts(accounts);
124
+ this.applySocialGate = (connected, options = {}) => {
126
125
  const wasConnected = this.isInstagramConnected;
127
126
  this.isInstagramConnected = connected;
128
127
  if (!connected) {
@@ -136,9 +135,15 @@ export class WebChat {
136
135
  void this.loadConversationsAfterInstagramConnect();
137
136
  }
138
137
  };
139
- this.refreshInstagramConnectionGate = async () => {
140
- const data = await getSocialAccounts({ platform: 'instagram' });
141
- this.applyInstagramAccounts((data === null || data === void 0 ? void 0 : data.accounts) || [], { bootstrap: true });
138
+ /** Unlock when Instagram OR LinkedIn has at least one connected account. */
139
+ this.refreshInstagramConnectionGate = async (options = { bootstrap: true }) => {
140
+ const [igData, liData] = await Promise.all([
141
+ getSocialAccounts({ platform: 'instagram' }).catch(() => ({ accounts: [] })),
142
+ getSocialAccounts({ platform: 'linkedin' }).catch(() => ({ accounts: [] })),
143
+ ]);
144
+ const connected = hasConnectedInstagramAccounts((igData === null || igData === void 0 ? void 0 : igData.accounts) || []) ||
145
+ hasConnectedInstagramAccounts((liData === null || liData === void 0 ? void 0 : liData.accounts) || []);
146
+ this.applySocialGate(connected, options);
142
147
  };
143
148
  this.loadConversationsAfterInstagramConnect = async () => {
144
149
  if (!this.isInstagramConnected)
@@ -154,14 +159,14 @@ export class WebChat {
154
159
  await this.getConversations();
155
160
  }
156
161
  catch (error) {
157
- console.error('Failed to load conversations after Instagram connect:', error);
162
+ console.error('Failed to load conversations after social connect:', error);
158
163
  }
159
164
  finally {
160
165
  this.isConversationLoading = false;
161
166
  }
162
167
  };
163
- this.handleInstagramAccountsChange = (accounts = []) => {
164
- this.applyInstagramAccounts(accounts);
168
+ this.handleInstagramAccountsChange = (_accounts) => {
169
+ void this.refreshInstagramConnectionGate({ bootstrap: false });
165
170
  };
166
171
  this.openChatTab = () => {
167
172
  if (this.isInstagramConnected) {
@@ -852,18 +857,18 @@ export class WebChat {
852
857
  catch (userError) {
853
858
  console.error('Failed to get user details:', userError);
854
859
  }
855
- // Gate chats behind a connected Instagram account
860
+ // Gate chats behind any connected social account (Instagram or LinkedIn)
856
861
  try {
857
- this.updateLoading(65, 'Checking Instagram connection...');
862
+ this.updateLoading(65, 'Checking social connections...');
858
863
  await this.refreshInstagramConnectionGate();
859
864
  }
860
865
  catch (igError) {
861
- console.error('Failed to check Instagram accounts:', igError);
862
- this.applyInstagramAccounts([]);
866
+ console.error('Failed to check social accounts:', igError);
867
+ this.applySocialGate(false, { bootstrap: true });
863
868
  }
864
869
  if (!this.isInstagramConnected) {
865
870
  this.activeTab = 'Accounts';
866
- this.updateLoading(100, 'Connect Instagram to continue');
871
+ this.updateLoading(100, 'Connect Instagram or LinkedIn to continue');
867
872
  this.checkMobileView();
868
873
  window.addEventListener('resize', this.checkMobileView.bind(this));
869
874
  return;
@@ -1975,7 +1980,7 @@ export class WebChat {
1975
1980
  }
1976
1981
  render() {
1977
1982
  var _a, _b, _c, _d, _e;
1978
- return (h(Fragment, { key: '120ba07af7eb93f1f6cbed603f6e25bfd48b0900' }, this.isLoading ? (h("chat-loading-placeholder", { progress: this.loadingProgress, loadingStatus: this.loadingStatus })) : (h(Fragment, null, this.isConversationLoading ? (h("div", { class: "loaderoverlay" }, h("spinner-loader", { height: "30px", width: "30px", spinTime: "1s", spinnerPrimaryColor: "var(--bg-primary-color)", spinnerSecondaryColor: "var(--text-primary-color)", spinnerBorderWidth: "2px" }))) : null, h("div", { class: {
1983
+ return (h(Fragment, { key: '48018669b503b2bb6fee4d774d69800cad5e913e' }, this.isLoading ? (h("chat-loading-placeholder", { progress: this.loadingProgress, loadingStatus: this.loadingStatus })) : (h(Fragment, null, this.isConversationLoading ? (h("div", { class: "loaderoverlay" }, h("spinner-loader", { height: "30px", width: "30px", spinTime: "1s", spinnerPrimaryColor: "var(--bg-primary-color)", spinnerSecondaryColor: "var(--text-primary-color)", spinnerBorderWidth: "2px" }))) : null, h("div", { class: {
1979
1984
  'isometrik-quickchat': true,
1980
1985
  'is-resizing': this.isResizingSidebar,
1981
1986
  'is-instagram-gate': !this.isInstagramConnected,