@amityco/ts-sdk 6.20.1-84eace1.0 → 6.20.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.
Files changed (105) hide show
  1. package/.env +26 -26
  2. package/dist/@types/core/events.d.ts +7 -12
  3. package/dist/@types/core/events.d.ts.map +1 -1
  4. package/dist/@types/core/model.d.ts +3 -3
  5. package/dist/@types/core/model.d.ts.map +1 -1
  6. package/dist/@types/core/payload.d.ts +2 -2
  7. package/dist/@types/core/payload.d.ts.map +1 -1
  8. package/dist/@types/domains/channel.d.ts +0 -3
  9. package/dist/@types/domains/channel.d.ts.map +1 -1
  10. package/dist/@types/domains/reaction.d.ts +4 -8
  11. package/dist/@types/domains/reaction.d.ts.map +1 -1
  12. package/dist/channelRepository/api/getChannel.d.ts +2 -2
  13. package/dist/channelRepository/api/getChannel.d.ts.map +1 -1
  14. package/dist/channelRepository/api/getChannelByIds.d.ts +2 -2
  15. package/dist/channelRepository/api/getChannelByIds.d.ts.map +1 -1
  16. package/dist/channelRepository/observers/getChannel.d.ts.map +1 -1
  17. package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
  18. package/dist/channelRepository/observers/getChannels/ChannelQueryStreamController.d.ts.map +1 -1
  19. package/dist/channelRepository/observers/observeChannel.d.ts +1 -1
  20. package/dist/channelRepository/observers/observeChannel.d.ts.map +1 -1
  21. package/dist/channelRepository/utils/getSubChannelsUnreadCount.d.ts.map +1 -1
  22. package/dist/channelRepository/utils/prepateUnreadCountInfo.d.ts.map +1 -1
  23. package/dist/client/api/login.d.ts.map +1 -1
  24. package/dist/client/utils/ObjectResolver/objectResolverEngine.d.ts.map +1 -1
  25. package/dist/commentRepository/observers/getComments.d.ts.map +1 -1
  26. package/dist/core/events.d.ts +3 -3
  27. package/dist/core/events.d.ts.map +1 -1
  28. package/dist/index.cjs.js +158 -188
  29. package/dist/index.esm.js +158 -188
  30. package/dist/index.umd.js +4 -4
  31. package/dist/messageRepository/utils/prepareMessagePayload.d.ts +1 -1
  32. package/dist/messageRepository/utils/prepareMessagePayload.d.ts.map +1 -1
  33. package/dist/reactionRepository/api/addReaction.d.ts +2 -2
  34. package/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
  35. package/dist/reactionRepository/api/queryReactor.d.ts +3 -3
  36. package/dist/reactionRepository/api/queryReactor.d.ts.map +1 -1
  37. package/dist/reactionRepository/api/removeReaction.d.ts +2 -2
  38. package/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
  39. package/dist/reactionRepository/events/onReactorAdded.d.ts +2 -2
  40. package/dist/reactionRepository/events/onReactorAdded.d.ts.map +1 -1
  41. package/dist/reactionRepository/events/onReactorRemoved.d.ts +2 -2
  42. package/dist/reactionRepository/events/onReactorRemoved.d.ts.map +1 -1
  43. package/dist/reactionRepository/observers/getReactions.d.ts +1 -1
  44. package/dist/reactionRepository/observers/getReactions.d.ts.map +1 -1
  45. package/dist/reactionRepository/utils/prepareMessagePayloadForCache.d.ts +1 -1
  46. package/dist/reactionRepository/utils/prepareMessagePayloadForCache.d.ts.map +1 -1
  47. package/dist/streamRepository/events/onStreamStopped.d.ts.map +1 -1
  48. package/dist/utils/linkedObject/index.d.ts +0 -1
  49. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  50. package/dist/utils/tests/dummy/reaction.d.ts +1 -1
  51. package/dist/utils/tests/dummy/reaction.d.ts.map +1 -1
  52. package/package.json +1 -1
  53. package/src/@types/core/events.ts +7 -13
  54. package/src/@types/core/model.ts +3 -3
  55. package/src/@types/core/payload.ts +2 -2
  56. package/src/@types/domains/channel.ts +0 -3
  57. package/src/@types/domains/reaction.ts +4 -10
  58. package/src/channelRepository/api/getChannel.ts +7 -11
  59. package/src/channelRepository/api/getChannelByIds.ts +7 -13
  60. package/src/channelRepository/observers/getChannel.ts +0 -2
  61. package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +10 -14
  62. package/src/channelRepository/observers/getChannels/ChannelQueryStreamController.ts +5 -4
  63. package/src/channelRepository/utils/getChannelIsMentioned.ts +2 -2
  64. package/src/channelRepository/utils/getSubChannelsUnreadCount.ts +2 -3
  65. package/src/channelRepository/utils/prepareChannelPayload.ts +2 -2
  66. package/src/channelRepository/utils/prepateUnreadCountInfo.ts +1 -2
  67. package/src/client/api/login.ts +3 -1
  68. package/src/client/utils/ObjectResolver/objectResolverEngine.ts +4 -5
  69. package/src/commentRepository/events/onCommentReactionAdded.ts +1 -1
  70. package/src/commentRepository/events/onCommentReactionRemoved.ts +1 -1
  71. package/src/commentRepository/observers/getComments.ts +4 -5
  72. package/src/commentRepository/observers/tests/getComment.test.ts +2 -2
  73. package/src/core/events.ts +0 -4
  74. package/src/core/model/idResolvers.ts +1 -1
  75. package/src/core/query/filtering.ts +1 -1
  76. package/src/messageRepository/utils/prepareMessagePayload.ts +2 -2
  77. package/src/postRepository/observers/tests/getPost.test.ts +1 -1
  78. package/src/postRepository/observers/tests/getPosts.test.ts +1 -1
  79. package/src/reactionRepository/api/addReaction.ts +2 -2
  80. package/src/reactionRepository/api/queryReactor.ts +3 -3
  81. package/src/reactionRepository/api/removeReaction.ts +2 -2
  82. package/src/reactionRepository/events/onReactorAdded.ts +5 -5
  83. package/src/reactionRepository/events/onReactorRemoved.ts +5 -5
  84. package/src/reactionRepository/observers/getReactions.ts +16 -18
  85. package/src/reactionRepository/utils/prepareMessagePayloadForCache.ts +1 -1
  86. package/src/streamRepository/events/onStreamRecorded.ts +1 -1
  87. package/src/streamRepository/events/onStreamStarted.ts +1 -1
  88. package/src/streamRepository/events/onStreamStopped.ts +1 -6
  89. package/src/utils/linkedObject/index.ts +0 -2
  90. package/src/utils/tests/dummy/reaction.ts +1 -1
  91. package/dist/channelRepository/events/onChannelResolved.d.ts +0 -12
  92. package/dist/channelRepository/events/onChannelResolved.d.ts.map +0 -1
  93. package/dist/channelRepository/utils/resolveChannels.d.ts +0 -2
  94. package/dist/channelRepository/utils/resolveChannels.d.ts.map +0 -1
  95. package/dist/marker/events/onUserMessageFeedMarkerResolved.d.ts +0 -12
  96. package/dist/marker/events/onUserMessageFeedMarkerResolved.d.ts.map +0 -1
  97. package/dist/marker/utils/resolveUserMessageFeedMakers.d.ts +0 -2
  98. package/dist/marker/utils/resolveUserMessageFeedMakers.d.ts.map +0 -1
  99. package/dist/utils/linkedObject/reactorLinkedObject.d.ts +0 -2
  100. package/dist/utils/linkedObject/reactorLinkedObject.d.ts.map +0 -1
  101. package/src/channelRepository/events/onChannelResolved.ts +0 -22
  102. package/src/channelRepository/utils/resolveChannels.ts +0 -8
  103. package/src/marker/events/onUserMessageFeedMarkerResolved.ts +0 -29
  104. package/src/marker/utils/resolveUserMessageFeedMakers.ts +0 -17
  105. package/src/utils/linkedObject/reactorLinkedObject.ts +0 -13
package/dist/index.cjs.js CHANGED
@@ -98,8 +98,8 @@ const PostContentType = Object.freeze({
98
98
 
99
99
  function getVersion() {
100
100
  try {
101
- // the string ''v6.20.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
102
- return 'v6.20.0-cjs';
101
+ // the string ''v6.20.1-cjs'' should be replaced by actual value by @rollup/plugin-replace
102
+ return 'v6.20.1-cjs';
103
103
  }
104
104
  catch (error) {
105
105
  return '__dev__';
@@ -504,7 +504,7 @@ const idResolvers = {
504
504
  user: ({ userId }) => userId,
505
505
  file: ({ fileId }) => fileId,
506
506
  role: ({ roleId }) => roleId,
507
- channel: ({ channelInternalId }) => channelInternalId,
507
+ channel: ({ channelId }) => channelId,
508
508
  subChannel: ({ subChannelId }) => subChannelId,
509
509
  channelUsers: ({ channelId, userId }) => `${channelId}#${userId}`,
510
510
  message: ({ messageId }) => messageId,
@@ -1067,7 +1067,7 @@ const filterByChannelMembership = (collection, membership, userId) => {
1067
1067
  return true;
1068
1068
  // get resolver for the channel by user
1069
1069
  const channelUserCacheKey = getResolver('channelUsers')({
1070
- channelId: c.channelPublicId,
1070
+ channelId: c.channelId,
1071
1071
  userId,
1072
1072
  });
1073
1073
  const channelUser = (_a = pullFromCache([
@@ -1308,9 +1308,6 @@ const WS_EVENTS = [
1308
1308
  'sessionStateChange',
1309
1309
  // for internal use by accessTokenExpiryWatcher
1310
1310
  'tokenExpired',
1311
- 'v3.video-streaming.didRecord',
1312
- 'v3.video-streaming.didStart',
1313
- 'v3.video-streaming.didStop',
1314
1311
  ];
1315
1312
  const MQTT_EVENTS = [
1316
1313
  'connect',
@@ -5650,16 +5647,6 @@ const messageLinkedObject = (message) => {
5650
5647
  } });
5651
5648
  };
5652
5649
 
5653
- const reactorLinkedObject = (reactor) => {
5654
- return Object.assign(Object.assign({}, reactor), { get user() {
5655
- var _a;
5656
- const user = (_a = pullFromCache(['user', 'get', reactor.userId])) === null || _a === void 0 ? void 0 : _a.data;
5657
- if (!user)
5658
- return undefined;
5659
- return userLinkedObject(user);
5660
- } });
5661
- };
5662
-
5663
5650
  const LinkedObject = {
5664
5651
  comment: commentLinkedObject,
5665
5652
  post: postLinkedObject,
@@ -5668,7 +5655,6 @@ const LinkedObject = {
5668
5655
  story: storyLinkedObject,
5669
5656
  storyTarget: storyTargetLinkedObject,
5670
5657
  message: messageLinkedObject,
5671
- reactor: reactorLinkedObject,
5672
5658
  };
5673
5659
 
5674
5660
  const getChannelMessagePreviewWithUser = (channel) => {
@@ -5990,8 +5976,7 @@ const getSubChannelsUnreadCount = (channel, marker) => {
5990
5976
  var _a, _b, _c, _d, _e;
5991
5977
  const client = getActiveClient();
5992
5978
  if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
5993
- // Marker service API uses channelInternalId as channelId
5994
- return (_b = (_a = getUnreadInfoCached$1(channel.channelInternalId)) === null || _a === void 0 ? void 0 : _a.unreadCount) !== null && _b !== void 0 ? _b : 0;
5979
+ return (_b = (_a = getUnreadInfoCached$1(channel.channelId)) === null || _a === void 0 ? void 0 : _a.unreadCount) !== null && _b !== void 0 ? _b : 0;
5995
5980
  }
5996
5981
  if (marker === null || marker === void 0 ? void 0 : marker.isDeleted) {
5997
5982
  // NOTE: This is a temporary solution to handle the channel marker when the user is forced to
@@ -5999,7 +5984,7 @@ const getSubChannelsUnreadCount = (channel, marker) => {
5999
5984
  // from a channel or the channel is deleted the channel's unread count will reset to zero
6000
5985
  return 0;
6001
5986
  }
6002
- return (_e = (_c = marker === null || marker === void 0 ? void 0 : marker.unreadCount) !== null && _c !== void 0 ? _c : (_d = getCachedMarker$1(channel.channelInternalId)) === null || _d === void 0 ? void 0 : _d.unreadCount) !== null && _e !== void 0 ? _e : 0;
5987
+ return (_e = (_c = marker === null || marker === void 0 ? void 0 : marker.unreadCount) !== null && _c !== void 0 ? _c : (_d = getCachedMarker$1(channel.channelId)) === null || _d === void 0 ? void 0 : _d.unreadCount) !== null && _e !== void 0 ? _e : 0;
6003
5988
  };
6004
5989
 
6005
5990
  const getCachedMarker = (entityId) => {
@@ -6030,11 +6015,11 @@ const getChannelIsMentioned = (channel, marker) => {
6030
6015
  var _a, _b, _c, _d;
6031
6016
  const client = getActiveClient();
6032
6017
  if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
6033
- return (_b = (_a = getUnreadInfoCached(channel.channelPublicId)) === null || _a === void 0 ? void 0 : _a.isMentioned) !== null && _b !== void 0 ? _b : false;
6018
+ return (_b = (_a = getUnreadInfoCached(channel.channelId)) === null || _a === void 0 ? void 0 : _a.isMentioned) !== null && _b !== void 0 ? _b : false;
6034
6019
  }
6035
6020
  return (marker === null || marker === void 0 ? void 0 : marker.hasMentioned) !== undefined
6036
6021
  ? marker === null || marker === void 0 ? void 0 : marker.hasMentioned
6037
- : (_d = (_c = getCachedMarker(channel.channelPublicId)) === null || _c === void 0 ? void 0 : _c.hasMentioned) !== null && _d !== void 0 ? _d : false;
6022
+ : (_d = (_c = getCachedMarker(channel.channelId)) === null || _c === void 0 ? void 0 : _c.hasMentioned) !== null && _d !== void 0 ? _d : false;
6038
6023
  };
6039
6024
 
6040
6025
  const MARKER_INCLUDED_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
@@ -6061,7 +6046,7 @@ function convertFromRaw$2(channel, options = { isMessagePreviewUpdated: true })
6061
6046
  },
6062
6047
  get subChannelsUnreadCount() {
6063
6048
  return getSubChannelsUnreadCount(channel);
6064
- } }, channel), { defaultSubChannelId: channel.channelInternalId, isUnreadCountSupport: isUnreadCountSupport$2(channel), messagePreviewId });
6049
+ } }, channel), { defaultSubChannelId: channel._id, isUnreadCountSupport: isUnreadCountSupport$2(channel), messagePreviewId });
6065
6050
  }
6066
6051
  const preUpdateChannelCache = (rawPayload, options = { isMessagePreviewUpdated: true }) => {
6067
6052
  ingestInCache({
@@ -6080,7 +6065,7 @@ const prepareChannelPayload = async (rawPayload, options = { isMessagePreviewUpd
6080
6065
  const markerIds = rawPayload.channels
6081
6066
  // filter channel by type. Only conversation, community and broadcast type are included.
6082
6067
  .filter(isUnreadCountSupport$2)
6083
- .map(({ channelInternalId }) => channelInternalId);
6068
+ .map(({ channelId }) => channelId);
6084
6069
  if (markerIds.length > 0) {
6085
6070
  // since the get markers method requires a channel cache to function with the reducer.
6086
6071
  preUpdateChannelCache(rawPayload, { isMessagePreviewUpdated: options.isMessagePreviewUpdated });
@@ -6100,85 +6085,6 @@ const prepareChannelPayload = async (rawPayload, options = { isMessagePreviewUpd
6100
6085
  channelUsers });
6101
6086
  };
6102
6087
 
6103
- /**
6104
- * ```js
6105
- * import { getSubChannelMarkers } from '@amityco/ts-sdk'
6106
- * const subChannelMarkers = await getSubChannelMarkers(['sch1', 'sch2'])
6107
- * ```
6108
- *
6109
- * Fetches a paginable list of {@link Amity.SubChannelMarker} objects
6110
- *
6111
- * @param messageFeedIds the feed IDs of the {@link Amity.RawSubChannel} marker to fetch
6112
- * @param page
6113
- * @returns A page of {@link Amity.SubChannelMarker} objects
6114
- *
6115
- * @category Channel API
6116
- * @async
6117
- * @private
6118
- */
6119
- const getUserMessageFeedMakers = async (channelIds) => {
6120
- const client = getActiveClient();
6121
- client.log('channel/getUserMessageFeedMakers', channelIds);
6122
- const { data } = await client.http.get(`/api/v1/markers/user-message-feed`, {
6123
- params: {
6124
- channelIds,
6125
- },
6126
- });
6127
- fireEvent('local.userMessageFeedMarker.fetched', { userMessageFeedMarker: data });
6128
- return data;
6129
- };
6130
-
6131
- const persistUnreadCountInfo = (payload) => {
6132
- const { feedMarkers, userFeedMarkers } = payload;
6133
- // calculate sub channel unread info and channel unread info
6134
- if (feedMarkers.length > 0 && userFeedMarkers.length > 0) {
6135
- const channelIds = [];
6136
- const feedMarkerMap = new Map(feedMarkers.map(fm => [fm.feedId, fm]));
6137
- userFeedMarkers.forEach(userFeedMarker => {
6138
- const feedMarker = feedMarkerMap.get(userFeedMarker.feedId);
6139
- if (!feedMarker)
6140
- return;
6141
- if (feedMarker.feedId === userFeedMarker.feedId) {
6142
- const unreadCount = feedMarker.lastSegment - userFeedMarker.readToSegment;
6143
- const subChannelUnreadInfo = {
6144
- subChannelId: feedMarker.feedId,
6145
- channelId: feedMarker.entityId,
6146
- readToSegment: userFeedMarker.readToSegment,
6147
- lastSegment: feedMarker.lastSegment,
6148
- lastMentionSegment: userFeedMarker.lastMentionSegment,
6149
- unreadCount: Math.max(0, unreadCount),
6150
- isMentioned: userFeedMarker.isMentioned,
6151
- isDeleted: feedMarker.isDeleted,
6152
- createdAt: userFeedMarker.createdAt,
6153
- updatedAt: userFeedMarker.updatedAt,
6154
- };
6155
- // update sub channel unread info in cache
6156
- ingestInCache({ subChannelUnreadInfo: [subChannelUnreadInfo] });
6157
- if (!channelIds.includes(feedMarker.entityId)) {
6158
- channelIds.push(feedMarker.entityId);
6159
- }
6160
- }
6161
- });
6162
- // re-calculate channel unread info in cache
6163
- channelIds.forEach(channelId => {
6164
- reCalculateChannelUnreadInfo(channelId);
6165
- });
6166
- }
6167
- };
6168
-
6169
- const prepareUnreadCountInfo = async (rawPayload) => {
6170
- const client = getActiveClient();
6171
- // if consistent mode is enabled, persist the unread count info to the cache
6172
- // Marker service API uses channelInternalId as channelId
6173
- const queryPayload = await getUserMessageFeedMakers(rawPayload.channels.map(({ channelInternalId }) => channelInternalId));
6174
- const { feedMarkers, userFeedMarkers } = queryPayload;
6175
- persistUnreadCountInfo({
6176
- feedMarkers,
6177
- userFeedMarkers,
6178
- });
6179
- client.log('channel/prepareUnreadCountInfo', rawPayload.channels);
6180
- };
6181
-
6182
6088
  /**
6183
6089
  * ```js
6184
6090
  * import { getChannelByIds } from '@amityco/ts-sdk'
@@ -6208,16 +6114,12 @@ const getChannelByIds = async (channelIds) => {
6208
6114
  catch (error) {
6209
6115
  channelIds.forEach(channelId => {
6210
6116
  if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
6211
- // NOTE: use channelPublicId as tombstone cache key since we cannot get the channelPrivateId that come along with channel data from server
6212
6117
  pushToTombstone('channel', channelId);
6213
6118
  }
6214
6119
  });
6215
6120
  throw error;
6216
6121
  }
6217
6122
  const data = await prepareChannelPayload(payload);
6218
- if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
6219
- await prepareUnreadCountInfo(payload);
6220
- }
6221
6123
  const cachedAt = client.cache && Date.now();
6222
6124
  if (client.cache)
6223
6125
  ingestInCache(data, { cachedAt });
@@ -6241,18 +6143,18 @@ const getChannelByIds = async (channelIds) => {
6241
6143
  * @category Channel API
6242
6144
  */
6243
6145
  getChannelByIds.locally = (channelIds) => {
6244
- var _a, _b;
6146
+ var _a;
6245
6147
  const client = getActiveClient();
6246
6148
  client.log('channel/getChannelByIds.locally', channelIds);
6247
6149
  if (!client.cache)
6248
6150
  return;
6249
- const cached = (_a = queryCache(['channel', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
6250
- return channelIds.includes(data.channelPublicId);
6251
- });
6252
- if (!cached || (cached === null || cached === void 0 ? void 0 : cached.length) < channelIds.length)
6151
+ const cached = channelIds
6152
+ .map(channelId => pullFromCache(['channel', 'get', channelId]))
6153
+ .filter(Boolean);
6154
+ if ((cached === null || cached === void 0 ? void 0 : cached.length) < channelIds.length)
6253
6155
  return;
6254
6156
  const channels = cached.map(({ data }) => data);
6255
- const oldest = (_b = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _b === void 0 ? void 0 : _b[0];
6157
+ const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
6256
6158
  return {
6257
6159
  data: channels,
6258
6160
  cachedAt: oldest.cachedAt,
@@ -6292,6 +6194,44 @@ const getMessageMarkers = async (messageIds) => {
6292
6194
  return { data: contentMarkers, cachedAt };
6293
6195
  };
6294
6196
 
6197
+ const persistUnreadCountInfo = (payload) => {
6198
+ const { feedMarkers, userFeedMarkers } = payload;
6199
+ // calculate sub channel unread info and channel unread info
6200
+ if (feedMarkers.length > 0 && userFeedMarkers.length > 0) {
6201
+ const channelIds = [];
6202
+ const feedMarkerMap = new Map(feedMarkers.map(fm => [fm.feedId, fm]));
6203
+ userFeedMarkers.forEach(userFeedMarker => {
6204
+ const feedMarker = feedMarkerMap.get(userFeedMarker.feedId);
6205
+ if (!feedMarker)
6206
+ return;
6207
+ if (feedMarker.feedId === userFeedMarker.feedId) {
6208
+ const unreadCount = feedMarker.lastSegment - userFeedMarker.readToSegment;
6209
+ const subChannelUnreadInfo = {
6210
+ subChannelId: feedMarker.feedId,
6211
+ channelId: feedMarker.entityId,
6212
+ readToSegment: userFeedMarker.readToSegment,
6213
+ lastSegment: feedMarker.lastSegment,
6214
+ lastMentionSegment: userFeedMarker.lastMentionSegment,
6215
+ unreadCount: Math.max(0, unreadCount),
6216
+ isMentioned: userFeedMarker.isMentioned,
6217
+ isDeleted: feedMarker.isDeleted,
6218
+ createdAt: userFeedMarker.createdAt,
6219
+ updatedAt: userFeedMarker.updatedAt,
6220
+ };
6221
+ // update sub channel unread info in cache
6222
+ ingestInCache({ subChannelUnreadInfo: [subChannelUnreadInfo] });
6223
+ if (!channelIds.includes(feedMarker.entityId)) {
6224
+ channelIds.push(feedMarker.entityId);
6225
+ }
6226
+ }
6227
+ });
6228
+ // re-calculate channel unread info in cache
6229
+ channelIds.forEach(channelId => {
6230
+ reCalculateChannelUnreadInfo(channelId);
6231
+ });
6232
+ }
6233
+ };
6234
+
6295
6235
  /**
6296
6236
  * ```js
6297
6237
  * import { getSubChannelMarkers } from '@amityco/ts-sdk'
@@ -7581,19 +7521,32 @@ const onOffline = (callback) => {
7581
7521
  return () => console.error('Unsupported environment');
7582
7522
  };
7583
7523
 
7584
- const resolveChannels = async (channelIds) => {
7585
- const { data: channels } = await getChannelByIds(channelIds);
7586
- fireEvent('local.channel.resolved', channels);
7587
- };
7588
-
7589
- const resolveUserMessageFeedMarkers = async (channelIds) => {
7590
- const queryPayload = await getUserMessageFeedMakers(channelIds);
7591
- const { feedMarkers, userFeedMarkers } = queryPayload;
7592
- persistUnreadCountInfo({
7593
- feedMarkers,
7594
- userFeedMarkers,
7524
+ /**
7525
+ * ```js
7526
+ * import { getSubChannelMarkers } from '@amityco/ts-sdk'
7527
+ * const subChannelMarkers = await getSubChannelMarkers(['sch1', 'sch2'])
7528
+ * ```
7529
+ *
7530
+ * Fetches a paginable list of {@link Amity.SubChannelMarker} objects
7531
+ *
7532
+ * @param messageFeedIds the feed IDs of the {@link Amity.RawSubChannel} marker to fetch
7533
+ * @param page
7534
+ * @returns A page of {@link Amity.SubChannelMarker} objects
7535
+ *
7536
+ * @category Channel API
7537
+ * @async
7538
+ * @private
7539
+ */
7540
+ const getUserMessageFeedMakers = async (channelIds) => {
7541
+ const client = getActiveClient();
7542
+ client.log('channel/getUserMessageFeedMakers', channelIds);
7543
+ const { data } = await client.http.get(`/api/v1/markers/user-message-feed`, {
7544
+ params: {
7545
+ channelIds,
7546
+ },
7595
7547
  });
7596
- fireEvent('local.userMessageFeedMarkers.resolved', { feedMarkers, userFeedMarkers });
7548
+ fireEvent('local.userMessageFeedMarker.fetched', { userMessageFeedMarker: data });
7549
+ return data;
7597
7550
  };
7598
7551
 
7599
7552
  class ObjectResolverEngine {
@@ -7660,9 +7613,9 @@ class ObjectResolverEngine {
7660
7613
  // Incase of failure: Ignore
7661
7614
  // Incase of success: Persist in Domain DB & Notify Live collection
7662
7615
  if (channelIds.length > 0)
7663
- resolveChannels(channelIds);
7616
+ getChannelByIds(channelIds);
7664
7617
  if (userMessageFeedMarkerIds.length > 0)
7665
- resolveUserMessageFeedMarkers(userMessageFeedMarkerIds);
7618
+ getUserMessageFeedMakers(userMessageFeedMarkerIds);
7666
7619
  // After sending request
7667
7620
  this.isResolvingTask = false;
7668
7621
  }
@@ -8732,7 +8685,9 @@ const login = async (params, sessionHandler, config) => {
8732
8685
  // FIXME: events are duplicated if connectClient is called few times without disconnectClient
8733
8686
  // wire websocket events to our event emitter
8734
8687
  proxyWebsocketEvents(client.ws, client.emitter);
8735
- client.ws.open();
8688
+ client.ws.once('connect', () => {
8689
+ client.ws.open();
8690
+ });
8736
8691
  client.userId = user.userId;
8737
8692
  client.sessionHandler = sessionHandler;
8738
8693
  /*
@@ -13148,7 +13103,7 @@ const onReactionRemoved = (referenceType, referenceId, callback) => {
13148
13103
  * })
13149
13104
  * ```
13150
13105
  *
13151
- * Fired when an {@link Amity.InternalReactor} has been added
13106
+ * Fired when an {@link Amity.Reactor} has been added
13152
13107
  *
13153
13108
  * @param {@link Amity.ReactableType} referenceType
13154
13109
  * @param {string} referenceId
@@ -13211,7 +13166,7 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
13211
13166
  * })
13212
13167
  * ```
13213
13168
  *
13214
- * Fired when an {@link Amity.InternalReactor} has been removed
13169
+ * Fired when an {@link Amity.Reactor} has been removed
13215
13170
  *
13216
13171
  * @param {@link Amity.ReactableType} referenceType
13217
13172
  * @param {string} referenceId
@@ -13318,10 +13273,10 @@ const queryReactions = async (query) => {
13318
13273
  * })
13319
13274
  * ```
13320
13275
  *
13321
- * Queries a paginable list of {@link Amity.InternalReactor} objects
13276
+ * Queries a paginable list of {@link Amity.Reactor} objects
13322
13277
  *
13323
13278
  * @param query The query parameters
13324
- * @returns A page of {@link Amity.InternalReactor} objects
13279
+ * @returns A page of {@link Amity.Reactor} objects
13325
13280
  *
13326
13281
  * @reaction Reaction API
13327
13282
  * @async
@@ -13347,7 +13302,7 @@ const queryReactor = async (query) => {
13347
13302
  * }, response => merge(reactions, response.data))
13348
13303
  * ```
13349
13304
  *
13350
- * Observe all mutations on a list of {@link Amity.InternalReactor} for a given target object
13305
+ * Observe all mutations on a list of {@link Amity.Reactor} for a given target object
13351
13306
  *
13352
13307
  * @param params for querying reactions
13353
13308
  * @param callback the function to call when new data are available
@@ -13377,7 +13332,7 @@ const getReactions = (params, callback, config) => {
13377
13332
  const reactions = (_a = data.data
13378
13333
  .map(reactorId => pullFromCache(['reactor', 'get', reactorId]))
13379
13334
  .filter(Boolean)
13380
- .map(({ data }) => LinkedObject.reactor(data))) !== null && _a !== void 0 ? _a : [];
13335
+ .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
13381
13336
  callback({
13382
13337
  onNextPage: onFetch,
13383
13338
  data: reactions,
@@ -13652,6 +13607,18 @@ const updateChannel = async (channelId, patch) => {
13652
13607
  };
13653
13608
  /* end_public_function */
13654
13609
 
13610
+ const prepareUnreadCountInfo = async (rawPayload) => {
13611
+ const client = getActiveClient();
13612
+ // if consistent mode is enabled, persist the unread count info to the cache
13613
+ const queryPayload = await getUserMessageFeedMakers(rawPayload.channels.map(({ channelId }) => channelId));
13614
+ const { feedMarkers, userFeedMarkers } = queryPayload;
13615
+ persistUnreadCountInfo({
13616
+ feedMarkers,
13617
+ userFeedMarkers,
13618
+ });
13619
+ client.log('channel/prepareUnreadCountInfo', rawPayload.channels);
13620
+ };
13621
+
13655
13622
  /**
13656
13623
  * ```js
13657
13624
  * import { getChannel } from '@amityco/ts-sdk'
@@ -13680,7 +13647,6 @@ const getChannel$1 = async (channelId) => {
13680
13647
  }
13681
13648
  catch (error) {
13682
13649
  if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
13683
- // NOTE: use channelPublicId as tombstone cache key since we cannot get the channelPrivateId that come along with channel data from server
13684
13650
  pushToTombstone('channel', channelId);
13685
13651
  }
13686
13652
  throw error;
@@ -13708,20 +13674,16 @@ const getChannel$1 = async (channelId) => {
13708
13674
  * @category Channel API
13709
13675
  */
13710
13676
  getChannel$1.locally = (channelId) => {
13711
- var _a;
13712
13677
  const client = getActiveClient();
13713
13678
  client.log('channel/getChannel.locally', channelId);
13714
13679
  if (!client.cache)
13715
13680
  return;
13716
- // use queryCache to get all channel caches and filter by channelPublicId since we use channelPrivateId as cache key
13717
- const cached = (_a = queryCache(['channel', 'get'])) === null || _a === void 0 ? void 0 : _a.filter(({ data }) => {
13718
- return data.channelPublicId === channelId;
13719
- });
13720
- if (!cached || (cached === null || cached === void 0 ? void 0 : cached.length) === 0)
13681
+ const cached = pullFromCache(['channel', 'get', channelId]);
13682
+ if (!cached)
13721
13683
  return;
13722
13684
  return {
13723
- data: cached[0].data,
13724
- cachedAt: cached[0].cachedAt,
13685
+ data: cached.data,
13686
+ cachedAt: cached.cachedAt,
13725
13687
  };
13726
13688
  };
13727
13689
 
@@ -16365,7 +16327,6 @@ const getChannel = (channelId, callback) => {
16365
16327
  await handleMessageCreated(message);
16366
16328
  if (message.channelId !== channelId)
16367
16329
  return;
16368
- // channelId from message is channelInternalId
16369
16330
  const channel = (_a = pullFromCache(['channel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
16370
16331
  if (!channel)
16371
16332
  return;
@@ -16385,7 +16346,6 @@ const getChannel = (channelId, callback) => {
16385
16346
  await handleMessageCreated(message);
16386
16347
  if (message.channelId !== channelId)
16387
16348
  return;
16388
- // channelId from message is channelInternalId
16389
16349
  const channel = (_a = pullFromCache(['channel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data;
16390
16350
  if (!channel)
16391
16351
  return;
@@ -16549,15 +16509,15 @@ class ChannelQueryStreamController extends QueryStreamController {
16549
16509
  if ([
16550
16510
  "onCreate" /* Amity.ChannelActionType.OnCreate */,
16551
16511
  "onJoin" /* Amity.ChannelActionType.OnJoin */,
16552
- "onResolve" /* Amity.ChannelActionType.OnResolve */,
16512
+ "onFetch" /* Amity.ChannelActionType.OnFetch */,
16513
+ "onUserMessageFeedMarkerFetch" /* Amity.ChannelActionType.OnUserMessageFeedMarkerFetch */,
16553
16514
  ].includes(action)) {
16554
- if (Array.isArray(payload)) {
16515
+ if (Array.isArray(payload))
16555
16516
  collection.data = [
16556
- ...new Set([...payload.map(getResolver('channel')), ...collection.data]),
16517
+ ...new Set([...payload.map(({ channelId }) => channelId), ...collection.data]),
16557
16518
  ];
16558
- }
16559
16519
  else
16560
- collection.data = [...new Set([payload.channelInternalId, ...collection.data])];
16520
+ collection.data = [...new Set([payload.channelId, ...collection.data])];
16561
16521
  }
16562
16522
  pushToCache(this.cacheKey, collection);
16563
16523
  this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
@@ -16568,50 +16528,62 @@ class ChannelQueryStreamController extends QueryStreamController {
16568
16528
  }
16569
16529
  }
16570
16530
 
16571
- const resolveUnreadInfoOnChannelEvent = (channel, callback) => {
16572
- const client = getActiveClient();
16573
- if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
16574
- const objectResolverEngine = ObjectResolverEngine$1.getInstance();
16575
- objectResolverEngine.resolve(channel.channelId, "userMessageFeedMarker" /* Amity.ReferenceType.USER_MESSAGE_FEED_MARKER */);
16576
- }
16577
- else
16578
- callback(channel);
16579
- };
16580
-
16581
16531
  /**
16582
- * Internal used only
16532
+ * ```js
16533
+ * import { onChannelFetched } from '@amityco/ts-sdk'
16534
+ * const dispose = onChannelFetched(channel => {
16535
+ * // ...
16536
+ * })
16537
+ * ```
16583
16538
  *
16584
- * Fired when any {@link Amity.Channel} have been resolved by Object resolver
16539
+ * Fired when any {@link Amity.Channel} list have been fetched
16585
16540
  *
16586
16541
  * @param callback The function to call when the event was fired
16587
16542
  * @returns an {@link Amity.Unsubscriber} function to stop listening
16588
16543
  *
16589
16544
  * @category Channel Events
16590
16545
  */
16591
- const onChannelResolved = (callback) => {
16546
+ const onChannelFetched = (callback) => {
16592
16547
  const client = getActiveClient();
16593
16548
  const filter = async (payload) => {
16594
16549
  callback(payload);
16595
16550
  };
16596
- return createEventSubscriber(client, 'onChannelResolved', 'local.channel.resolved', filter);
16551
+ return createEventSubscriber(client, 'onChannelFetched', 'local.channel.fetched', filter);
16597
16552
  };
16598
16553
 
16599
16554
  /**
16600
- * Internal used only
16555
+ * ```js
16556
+ * import { onFeedMarkerUpdated } from '@amityco/ts-sdk'
16557
+ * const dispose = onFeedMarkerUpdated(feedMarker => {
16558
+ * // ...
16559
+ * })
16560
+ * ```
16601
16561
  *
16602
- * Fired when an {@link Amity.userMessageFeedMarkers} has been resolved by Object Rsesolver
16562
+ * Fired when an {@link Amity.UserMessageFeedMarkerPayload} has been updated
16603
16563
  *
16604
16564
  * @param callback The function to call when the event was fired
16605
16565
  * @returns an {@link Amity.Unsubscriber} function to stop listening
16606
16566
  *
16607
- * @category MessageMarker Events
16567
+ * @category FeedMarker Events
16608
16568
  */
16609
- const onUserMessageFeedMarkerResolved = (callback) => {
16569
+ const onUserFeedMarkerFetched = (callback) => {
16610
16570
  const client = getActiveClient();
16611
16571
  const filter = (payload) => {
16612
- callback(payload);
16572
+ // update sub channel unread info and channel unread info in cache
16573
+ persistUnreadCountInfo(payload.userMessageFeedMarker);
16574
+ callback(payload.userMessageFeedMarker);
16613
16575
  };
16614
- return createEventSubscriber(client, 'userMessageFeedMarker/onUserMessageFeedMarkerResolved', 'local.userMessageFeedMarkers.resolved', filter);
16576
+ return createEventSubscriber(client, 'feedMarker/onUserFeedMarkerFetched', 'local.userMessageFeedMarker.fetched', filter);
16577
+ };
16578
+
16579
+ const resolveUnreadInfoOnChannelEvent = (channel, callback) => {
16580
+ const client = getActiveClient();
16581
+ if (client.isUnreadCountEnabled && client.getMarkerSyncConsistentMode()) {
16582
+ const objectResolverEngine = ObjectResolverEngine$1.getInstance();
16583
+ objectResolverEngine.resolve(channel.channelId, "userMessageFeedMarker" /* Amity.ReferenceType.USER_MESSAGE_FEED_MARKER */);
16584
+ }
16585
+ else
16586
+ callback(channel);
16615
16587
  };
16616
16588
 
16617
16589
  /* eslint-disable no-use-before-define */
@@ -16748,6 +16720,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
16748
16720
  getSubscriptions() {
16749
16721
  const subscriptions = [
16750
16722
  {
16723
+ // TODO: merge this code to another onMessageCreated in this file
16751
16724
  fn: convertEventPayload((callback) => {
16752
16725
  return onMessageCreatedMqtt(message => {
16753
16726
  var _a;
@@ -16758,7 +16731,6 @@ class ChannelLiveCollectionController extends LiveCollectionController {
16758
16731
  ])) === null || _a === void 0 ? void 0 : _a.data;
16759
16732
  if (!cacheData) {
16760
16733
  const objectResolverEngine = ObjectResolverEngine$1.getInstance();
16761
- // channelId from message event payload is channelInternalId
16762
16734
  objectResolverEngine.resolve(message.channelId, "channel" /* Amity.ReferenceType.CHANNEL */);
16763
16735
  }
16764
16736
  else {
@@ -16772,6 +16744,7 @@ class ChannelLiveCollectionController extends LiveCollectionController {
16772
16744
  action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
16773
16745
  },
16774
16746
  {
16747
+ // TODO: merge this code to another onMessageCreated in this file
16775
16748
  fn: convertEventPayload((callback) => {
16776
16749
  return onMessageCreatedLocal(message => {
16777
16750
  var _a;
@@ -16963,25 +16936,23 @@ class ChannelLiveCollectionController extends LiveCollectionController {
16963
16936
  action: "onUpdate" /* Amity.ChannelActionType.OnUpdate */,
16964
16937
  },
16965
16938
  {
16966
- fn: onChannelResolved,
16967
- action: "onResolve" /* Amity.ChannelActionType.OnResolve */,
16939
+ fn: onChannelFetched,
16940
+ action: "onFetch" /* Amity.ChannelActionType.OnFetch */,
16968
16941
  },
16969
16942
  {
16970
16943
  fn: (callback) => {
16971
- const handleUserFeedMarkerResolved = async (marker) => {
16944
+ const handleUserFeedMarkerFetch = async (marker) => {
16972
16945
  if (marker.feedMarkers) {
16973
- const channelIds = [
16974
- ...new Set(marker.feedMarkers.map(feedMarker => feedMarker.entityId)),
16975
- ];
16946
+ const channelIds = marker.feedMarkers.map(feedMarker => feedMarker.entityId);
16976
16947
  const channels = channelIds
16977
16948
  .map(channelId => { var _a; return (_a = pullFromCache(['channel', 'get', channelId])) === null || _a === void 0 ? void 0 : _a.data; })
16978
16949
  .filter(Boolean);
16979
16950
  callback(channels);
16980
16951
  }
16981
16952
  };
16982
- return onUserMessageFeedMarkerResolved(handleUserFeedMarkerResolved);
16953
+ return onUserFeedMarkerFetched(handleUserFeedMarkerFetch);
16983
16954
  },
16984
- action: "onResolve" /* Amity.ChannelActionType.OnResolve */,
16955
+ action: "onUserMessageFeedMarkerFetch" /* Amity.ChannelActionType.OnUserMessageFeedMarkerFetch */,
16985
16956
  },
16986
16957
  ];
16987
16958
  if (this.paginationController instanceof PaginationController) {
@@ -21253,6 +21224,7 @@ const getComments = (params, callback, config) => {
21253
21224
  const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
21254
21225
  const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
21255
21226
  const disposers = [];
21227
+ const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
21256
21228
  const cacheKey = [
21257
21229
  'comment',
21258
21230
  'collection',
@@ -21260,6 +21232,7 @@ const getComments = (params, callback, config) => {
21260
21232
  referenceId: params.referenceType,
21261
21233
  referenceType: params.referenceId,
21262
21234
  parentId: (params === null || params === void 0 ? void 0 : params.parentId) || '',
21235
+ sortBy,
21263
21236
  },
21264
21237
  ];
21265
21238
  const responder = (data) => {
@@ -21272,7 +21245,6 @@ const getComments = (params, callback, config) => {
21272
21245
  if (!params.includeDeleted) {
21273
21246
  comments = filterByPropEquality(comments, 'isDeleted', false);
21274
21247
  }
21275
- const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
21276
21248
  comments = comments.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
21277
21249
  callback({
21278
21250
  onNextPage: onFetch,
@@ -21307,9 +21279,7 @@ const getComments = (params, callback, config) => {
21307
21279
  return;
21308
21280
  const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { limit: queryLimit, page: !initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined }));
21309
21281
  runQuery(query, ({ data: result, error, loading, paging }) => {
21310
- // depend on sortBy value we have two different pagination types
21311
- const sorting = queryParams.sortBy || 'lastCreated';
21312
- const page = sorting === 'lastCreated' ? paging === null || paging === void 0 ? void 0 : paging.next : paging === null || paging === void 0 ? void 0 : paging.previous;
21282
+ const page = paging === null || paging === void 0 ? void 0 : paging.next;
21313
21283
  const data = {
21314
21284
  loading,
21315
21285
  error,
@@ -21606,7 +21576,7 @@ const onStreamStarted = (callback) => {
21606
21576
  ingestInCache(payload);
21607
21577
  callback(payload.videoStreamings[0]);
21608
21578
  };
21609
- return createEventSubscriber(client, 'stream/onStreamStarted', 'v3.video-streaming.didStart', filter);
21579
+ return createEventSubscriber(client, 'stream/onStreamStarted', 'video-streaming.didStart', filter);
21610
21580
  };
21611
21581
 
21612
21582
  /**
@@ -21630,7 +21600,7 @@ const onStreamStopped = (callback) => {
21630
21600
  ingestInCache(payload);
21631
21601
  callback(payload.videoStreamings[0]);
21632
21602
  };
21633
- return createEventSubscriber(client, 'stream/onStreamStropped', 'v3.video-streaming.didStop', filter);
21603
+ return createEventSubscriber(client, 'stream/onStreamStarted', 'video-streaming.didStop', filter);
21634
21604
  };
21635
21605
 
21636
21606
  /**
@@ -21654,7 +21624,7 @@ const onStreamRecorded = (callback) => {
21654
21624
  ingestInCache(payload);
21655
21625
  callback(payload.videoStreamings[0]);
21656
21626
  };
21657
- return createEventSubscriber(client, 'stream/onStreamRecorded', 'v3.video-streaming.didRecord', filter);
21627
+ return createEventSubscriber(client, 'stream/onStreamRecorded', 'video-streaming.didRecord', filter);
21658
21628
  };
21659
21629
 
21660
21630
  /* eslint-disable no-use-before-define */
@@ -22188,7 +22158,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
22188
22158
  getPoll: getPoll
22189
22159
  });
22190
22160
 
22191
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
22161
+ const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
22192
22162
  /*
22193
22163
  * The crypto algorithm used for importing key and signing string
22194
22164
  */