plogme 1.0.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.
Files changed (154) hide show
  1. package/LICENSE +61 -0
  2. package/README.md +212 -0
  3. package/WAProto/V +1 -0
  4. package/WAProto/WAProto.proto +8051 -0
  5. package/WAProto/index.js +289292 -0
  6. package/engine-requirements.js +51 -0
  7. package/lib/Defaults/ban-checker.js +44 -0
  8. package/lib/Defaults/index.js +158 -0
  9. package/lib/Signal/Group/ciphertext-message.js +11 -0
  10. package/lib/Signal/Group/group-session-builder.js +29 -0
  11. package/lib/Signal/Group/group_cipher.js +81 -0
  12. package/lib/Signal/Group/index.js +11 -0
  13. package/lib/Signal/Group/keyhelper.js +17 -0
  14. package/lib/Signal/Group/sender-chain-key.js +25 -0
  15. package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
  16. package/lib/Signal/Group/sender-key-message.js +65 -0
  17. package/lib/Signal/Group/sender-key-name.js +47 -0
  18. package/lib/Signal/Group/sender-key-record.js +40 -0
  19. package/lib/Signal/Group/sender-key-state.js +83 -0
  20. package/lib/Signal/Group/sender-message-key.js +25 -0
  21. package/lib/Signal/libsignal.js +428 -0
  22. package/lib/Signal/lid-mapping.js +280 -0
  23. package/lib/Socket/Client/index.js +2 -0
  24. package/lib/Socket/Client/types.js +10 -0
  25. package/lib/Socket/Client/websocket.js +53 -0
  26. package/lib/Socket/aigroups.js +315 -0
  27. package/lib/Socket/ban-checker.js +153 -0
  28. package/lib/Socket/business.js +407 -0
  29. package/lib/Socket/chats.js +1831 -0
  30. package/lib/Socket/chats.js[old] +1227 -0
  31. package/lib/Socket/communities.js +431 -0
  32. package/lib/Socket/graphql.js +899 -0
  33. package/lib/Socket/groups.js +549 -0
  34. package/lib/Socket/groups.js[old] +347 -0
  35. package/lib/Socket/index.js +71 -0
  36. package/lib/Socket/interactive-handler.js +600 -0
  37. package/lib/Socket/interop.js +563 -0
  38. package/lib/Socket/managed-account.js +208 -0
  39. package/lib/Socket/messages-recv.js +2144 -0
  40. package/lib/Socket/messages-send.js +2650 -0
  41. package/lib/Socket/messages-send.js[latest working] +1759 -0
  42. package/lib/Socket/mex.js +41 -0
  43. package/lib/Socket/newsletter.js +226 -0
  44. package/lib/Socket/privacy.js +446 -0
  45. package/lib/Socket/registration.js +428 -0
  46. package/lib/Socket/socket.js +1050 -0
  47. package/lib/Socket/username.js +229 -0
  48. package/lib/Store/index.js +4 -0
  49. package/lib/Store/make-cache-manager-store.js +89 -0
  50. package/lib/Store/make-in-memory-store.js +420 -0
  51. package/lib/Store/make-ordered-dictionary.js +78 -0
  52. package/lib/Store/object-repository.js +23 -0
  53. package/lib/Types/Auth.js +1 -0
  54. package/lib/Types/Bussines.js +1 -0
  55. package/lib/Types/Call.js +1 -0
  56. package/lib/Types/Chat.js +7 -0
  57. package/lib/Types/Contact.js +1 -0
  58. package/lib/Types/Events.js +1 -0
  59. package/lib/Types/GroupMetadata.js +1 -0
  60. package/lib/Types/Label.js +24 -0
  61. package/lib/Types/LabelAssociation.js +6 -0
  62. package/lib/Types/Message.js +17 -0
  63. package/lib/Types/Mex.js +39 -0
  64. package/lib/Types/Product.js +1 -0
  65. package/lib/Types/RichType.js +22 -0
  66. package/lib/Types/Signal.js +1 -0
  67. package/lib/Types/Socket.js +2 -0
  68. package/lib/Types/State.js +48 -0
  69. package/lib/Types/USync.js +1 -0
  70. package/lib/Types/index.js +25 -0
  71. package/lib/Utils/auth-utils.js +301 -0
  72. package/lib/Utils/bot-planning-replay.js +169 -0
  73. package/lib/Utils/browser-utils.js +28 -0
  74. package/lib/Utils/business.js +230 -0
  75. package/lib/Utils/channel-policy.js +1 -0
  76. package/lib/Utils/chat-utils.js +885 -0
  77. package/lib/Utils/chat-utils.js[old] +871 -0
  78. package/lib/Utils/companion-reg-client-utils.js +32 -0
  79. package/lib/Utils/consumer-application.js +102 -0
  80. package/lib/Utils/crypto.js +117 -0
  81. package/lib/Utils/decode-wa-message.js +484 -0
  82. package/lib/Utils/event-buffer.js +589 -0
  83. package/lib/Utils/games/slot-machine.js +258 -0
  84. package/lib/Utils/games/website-preview.js +293 -0
  85. package/lib/Utils/generics.js +390 -0
  86. package/lib/Utils/generics.js@old +385 -0
  87. package/lib/Utils/group-history.js +56 -0
  88. package/lib/Utils/history.js +130 -0
  89. package/lib/Utils/identity-change-handler.js +48 -0
  90. package/lib/Utils/index.js +35 -0
  91. package/lib/Utils/integrity.js +296 -0
  92. package/lib/Utils/jid-display-normalization.js +209 -0
  93. package/lib/Utils/link-preview.js +84 -0
  94. package/lib/Utils/logger.js +2 -0
  95. package/lib/Utils/lt-hash.js +7 -0
  96. package/lib/Utils/make-mutex.js +32 -0
  97. package/lib/Utils/message-composer.js +467 -0
  98. package/lib/Utils/message-inspect.js +67 -0
  99. package/lib/Utils/message-retry-manager.js +241 -0
  100. package/lib/Utils/messages-media.js +1006 -0
  101. package/lib/Utils/messages-media.js[old] +916 -0
  102. package/lib/Utils/messages.js +1982 -0
  103. package/lib/Utils/messages.js[old] +1902 -0
  104. package/lib/Utils/meta-ai-msmsg.js +130 -0
  105. package/lib/Utils/meta-compositing.js +202 -0
  106. package/lib/Utils/native-flow.js +100 -0
  107. package/lib/Utils/noise-handler.js +200 -0
  108. package/lib/Utils/offline-node-processor.js +39 -0
  109. package/lib/Utils/pre-key-manager.js +105 -0
  110. package/lib/Utils/process-message.js +582 -0
  111. package/lib/Utils/reporting-utils.js +257 -0
  112. package/lib/Utils/rich-message-utils.js +942 -0
  113. package/lib/Utils/rich-message-utils.js[Old] +387 -0
  114. package/lib/Utils/signal.js +200 -0
  115. package/lib/Utils/stanza-ack.js +37 -0
  116. package/lib/Utils/sync-action-utils.js +47 -0
  117. package/lib/Utils/tc-token-utils.js +162 -0
  118. package/lib/Utils/use-multi-file-auth-state.js +120 -0
  119. package/lib/Utils/use-single-file-auth-state.js +96 -0
  120. package/lib/Utils/use-sqlite-auth-state.js +108 -0
  121. package/lib/Utils/validate-connection.js +206 -0
  122. package/lib/Utils/view-once-utils.js +206 -0
  123. package/lib/Utils/voip-rekey.js +20 -0
  124. package/lib/Utils/welcome-flow.js +220 -0
  125. package/lib/WABinary/constants.js +1463 -0
  126. package/lib/WABinary/decode.js +261 -0
  127. package/lib/WABinary/encode.js +219 -0
  128. package/lib/WABinary/generic-utils.js +227 -0
  129. package/lib/WABinary/index.js +5 -0
  130. package/lib/WABinary/jid-utils.js +95 -0
  131. package/lib/WABinary/types.js +1 -0
  132. package/lib/WAM/BinaryInfo.js +9 -0
  133. package/lib/WAM/constants.js +22852 -0
  134. package/lib/WAM/encode.js +149 -0
  135. package/lib/WAM/index.js +3 -0
  136. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +96 -0
  137. package/lib/WAUSync/Protocols/USyncContactProtocol.js +56 -0
  138. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
  139. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
  140. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +70 -0
  141. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +28 -0
  142. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +25 -0
  143. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
  144. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +34 -0
  145. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
  146. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
  147. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
  148. package/lib/WAUSync/Protocols/index.js +12 -0
  149. package/lib/WAUSync/USyncQuery.js +201 -0
  150. package/lib/WAUSync/USyncUser.js +54 -0
  151. package/lib/WAUSync/index.js +3 -0
  152. package/lib/index.d.ts +406 -0
  153. package/lib/index.js +11 -0
  154. package/package.json +125 -0
@@ -0,0 +1,942 @@
1
+ /**
2
+ * Lia@Changes 09-04-26 [WIP]
3
+ * Adds support for tables and code blocks with richResponseMessage (wrapped inside botForwardedMessage).
4
+ *
5
+ * If you use or copy this code, please credit my name or project. AND DO NOT CHANGE THIS NOTE
6
+ */
7
+ import { getRandomValues, randomUUID, randomBytes } from 'crypto';
8
+ import { DONATE_URL, LEXER_REGEX } from '../Defaults/index.js';
9
+ import { LANGUAGE_KEYWORDS } from '../WABinary/constants.js';
10
+ import { CodeHighlightType, RichSubMessageType } from '../Types/RichType.js';
11
+ import { proto } from '../../WAProto/index.js';
12
+ import { unixTimestampSeconds } from './generics.js';
13
+ const NOOP = new Set([]);
14
+ export const tokenizeCode = (code, language = 'javascript') => {
15
+ const keywords = LANGUAGE_KEYWORDS[language] || NOOP;
16
+ const blocks = [];
17
+ LEXER_REGEX.lastIndex = 0;
18
+ let match;
19
+ while ((match = LEXER_REGEX.exec(code)) !== null) {
20
+ if (match[1]) {
21
+ blocks.push({ highlightType: CodeHighlightType.COMMENT, codeContent: match[1] });
22
+ }
23
+ else if (match[2]) {
24
+ blocks.push({ highlightType: CodeHighlightType.STRING, codeContent: match[2] });
25
+ }
26
+ else if (match[3]) {
27
+ blocks.push({
28
+ highlightType: keywords.has(match[3]) ? CodeHighlightType.KEYWORD : CodeHighlightType.METHOD,
29
+ codeContent: match[3],
30
+ });
31
+ }
32
+ else if (match[4]) {
33
+ blocks.push({
34
+ highlightType: keywords.has(match[4]) ? CodeHighlightType.KEYWORD : CodeHighlightType.DEFAULT,
35
+ codeContent: match[4],
36
+ });
37
+ }
38
+ else if (match[5]) {
39
+ blocks.push({ highlightType: CodeHighlightType.NUMBER, codeContent: match[5] });
40
+ }
41
+ else {
42
+ blocks.push({ highlightType: CodeHighlightType.DEFAULT, codeContent: match[6] });
43
+ }
44
+ }
45
+ return blocks;
46
+ };
47
+ // Lia@Changes 09-04-26 --- Inject buffer into unifiedResponse.data to support proper rendering of rich messages (ex: tables and code blocks)
48
+ export const toUnified = (submessages, uuid) => ({
49
+ response_id: uuid || randomUUID(),
50
+ sections: submessages.map((submessage) => {
51
+ switch (submessage.messageType) {
52
+ case RichSubMessageType.CODE: {
53
+ const codeMetadata = submessage.codeMetadata || {};
54
+ return {
55
+ view_model: {
56
+ primitive: {
57
+ language: codeMetadata.codeLanguage || 'javascript',
58
+ code_blocks: (codeMetadata.codeBlocks || []).map((block) => ({ content: block.codeContent, type: CodeHighlightType[block.highlightType] || 'DEFAULT' })),
59
+ __typename: 'GenAICodeUXPrimitive'
60
+ },
61
+ __typename: 'GenAISingleLayoutViewModel'
62
+ }
63
+ };
64
+ }
65
+ case RichSubMessageType.CONTENT_ITEMS: {
66
+ const items = submessage.contentItemsMetadata?.itemsMetadata || [];
67
+ const primitives = items.map((item) => {
68
+ const reel = item?.reelItem || item || {};
69
+ return {
70
+ reels_url: reel.videoUrl || reel.reels_url || reel.url || '',
71
+ thumbnail_url: reel.thumbnailUrl || reel.thumbnail_url || '',
72
+ creator: reel.creator || reel.title || '',
73
+ avatar_url: reel.profileIconUrl || reel.avatar_url || '',
74
+ reels_title: reel.title || reel.reels_title || '',
75
+ likes_count: reel.likesCount ?? reel.likes_count ?? 0,
76
+ shares_count: reel.sharesCount ?? reel.shares_count ?? 0,
77
+ view_count: reel.viewCount ?? reel.view_count ?? 0,
78
+ reel_source: reel.reelSource || reel.reel_source || 'IG',
79
+ is_verified: !!(reel.isVerified ?? reel.is_verified),
80
+ __typename: 'GenAIReelPrimitive'
81
+ };
82
+ }).filter((item) => item.reels_url || item.thumbnail_url || item.reels_title);
83
+ return {
84
+ view_model: {
85
+ primitives,
86
+ __typename: 'GenAIHScrollLayoutViewModel'
87
+ }
88
+ };
89
+ }
90
+ case RichSubMessageType.INLINE_IMAGE: {
91
+ const image = submessage.imageMetadata || {};
92
+ const media = mediaPrimitive({ url: image.imageUrl || image.url, mime_type: image.mimeType || image.mime_type, width: image.width, height: image.height });
93
+ return media ? { view_model: { primitive: media, __typename: 'GenAISingleLayoutViewModel' } } : {};
94
+ }
95
+ case RichSubMessageType.LATEX: {
96
+ const metadata = submessage.latexMetadata || {};
97
+ const expression = (metadata.expressions || [])[0] || {};
98
+ const item = {
99
+ latex_expression: expression.latexExpression || expression.expression || '',
100
+ font_height: expression.fontHeight,
101
+ padding: expression.padding ?? 15,
102
+ latex_image: {
103
+ url: expression.url || '',
104
+ width: expression.width || 388,
105
+ height: expression.height || 160
106
+ }
107
+ };
108
+ return {
109
+ view_model: {
110
+ primitive: { item, ...item, __typename: 'GenAILatexUXPrimitive' },
111
+ __typename: 'GenAISingleLayoutViewModel'
112
+ }
113
+ };
114
+ }
115
+ case RichSubMessageType.TABLE: {
116
+ const tableMetadata = submessage.tableMetadata || {};
117
+ return {
118
+ view_model: {
119
+ primitive: {
120
+ title: tableMetadata.title || '',
121
+ rows: (tableMetadata.rows || []).map((row) => ({
122
+ is_header: !!row.isHeading,
123
+ cells: row.items || [],
124
+ markdown_cells: (row.items || []).map((item) => ({ text: item }))
125
+ })),
126
+ __typename: 'GenATableUXPrimitive'
127
+ },
128
+ __typename: 'GenAISingleLayoutViewModel'
129
+ }
130
+ };
131
+ }
132
+ case RichSubMessageType.TEXT:
133
+ return {
134
+ view_model: {
135
+ primitive: {
136
+ text: submessage.messageText || '',
137
+ inline_entities: submessage.inlineEntities || [],
138
+ __typename: 'GenAIMarkdownTextUXPrimitive'
139
+ },
140
+ __typename: 'GenAISingleLayoutViewModel'
141
+ }
142
+ };
143
+ default:
144
+ return submessage;
145
+ }
146
+ })
147
+ });
148
+ /**
149
+ * Build the Meta-style AI image/video primitive used for generation states.
150
+ * This is intentionally additive: existing reels, tables, links, and menus keep
151
+ * their current wire format.
152
+ */
153
+ export const buildImaginePrimitive = ({
154
+ mediaType = 'video',
155
+ url = '',
156
+ thumbnail,
157
+ mimeType,
158
+ fileLength = 0,
159
+ duration = 0,
160
+ status = 'GENERATING',
161
+ estimatedMs,
162
+ imagineType
163
+ } = {}) => {
164
+ const normalizedType = String(mediaType).toLowerCase() === 'image' ? 'IMAGE' : 'ANIMATE';
165
+ const primitive = {
166
+ media: {
167
+ url: url || '',
168
+ mime_type: mimeType || (normalizedType === 'IMAGE' ? 'image/jpeg' : 'video/mp4'),
169
+ file_length: fileLength || 0,
170
+ duration: duration || 0
171
+ },
172
+ imagine_type: imagineType || normalizedType,
173
+ status: { status: String(status || 'GENERATING').toUpperCase() },
174
+ __typename: 'GenAIImaginePrimitive'
175
+ };
176
+ if (estimatedMs != null) {
177
+ primitive.status.estimated_completion_time = Math.floor((Date.now() + Number(estimatedMs)) / 1000);
178
+ }
179
+ if (thumbnail) primitive.thumbnail = { raw_media: thumbnail };
180
+ return primitive;
181
+ };
182
+
183
+ /**
184
+ * Prepare a native rich-response message containing a generation primitive.
185
+ * `itemId` is returned to callers so a later edit can replace the same item.
186
+ */
187
+ export const prepareRichGenerationMessage = ({
188
+ text = '',
189
+ mediaType = 'video',
190
+ url = '',
191
+ thumbnail,
192
+ mimeType,
193
+ fileLength = 0,
194
+ duration = 0,
195
+ status = 'GENERATING',
196
+ estimatedMs,
197
+ itemId = `imagine_${randomUUID()}`,
198
+ responseId = randomUUID(),
199
+ forwarded = true
200
+ } = {}) => {
201
+ const sections = [];
202
+ if (text) {
203
+ sections.push({ view_model: { primitive: { text: String(text), inline_entities: [], __typename: 'GenAIMarkdownTextUXPrimitive' }, __typename: 'GenAISingleLayoutViewModel' } });
204
+ }
205
+ sections.push({ view_model: { primitive: buildImaginePrimitive({ mediaType, url, thumbnail, mimeType, fileLength, duration, status, estimatedMs }), __typename: 'GenAISingleLayoutViewModel', id: itemId } });
206
+ const submessages = text ? [{ messageType: RichSubMessageType.TEXT, messageText: String(text) }] : [];
207
+ const richResponseMessage = proto.AIRichResponseMessage.create({
208
+ submessages,
209
+ messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
210
+ unifiedResponse: { data: Buffer.from(JSON.stringify({ response_id: responseId, sections })) },
211
+ contextInfo: forwarded ? { isForwarded: true, forwardingScore: 1, forwardedAiBotMessageInfo: { botJid: '867051314767696@bot' }, forwardOrigin: 4 } : {}
212
+ });
213
+ const message = wrapToBotForwardedMessage(richResponseMessage);
214
+ message.messageContextInfo = message.messageContextInfo || {};
215
+ message.messageContextInfo.botMetadata = {
216
+ ...(message.messageContextInfo.botMetadata || {}),
217
+ botResponseId: responseId
218
+ };
219
+ return { message, responseId, itemId };
220
+ };
221
+
222
+ // Lia@Note 17-04-26 --- WIP
223
+ export const buildAdditionalBotMetadataContext = (submessages) => {
224
+ const sources = [];
225
+ const mediaDetailsMetadataList = [];
226
+ for (let i = 0; i < submessages.length; i++) {
227
+ const submessage = submessages[i];
228
+ switch (submessage.messageType) {
229
+ case RichSubMessageType.CONTENT_ITEMS: {
230
+ const itemsMetadata = submessage.contentItemsMetadata?.itemsMetadata || [];
231
+ for (let n = 0; n < itemsMetadata.length; n++) {
232
+ const reelItem = itemsMetadata[n]?.reelItem || itemsMetadata[n] || {};
233
+ sources.push({
234
+ provider: 0,
235
+ thumbnailCdnUrl: reelItem.thumbnailUrl || reelItem.thumbnail_url || '',
236
+ sourceProviderUrl: reelItem.videoUrl || reelItem.reels_url || reelItem.url || '',
237
+ sourceQuery: '',
238
+ faviconCdnUrl: reelItem.profileIconUrl || reelItem.avatar_url || '',
239
+ citationNumber: i + 1,
240
+ sourceTitle: reelItem.title || reelItem.reels_title || reelItem.creator || ''
241
+ });
242
+ mediaDetailsMetadataList.push({
243
+ id: randomBytes(32).toString('hex'),
244
+ previewMedia: {
245
+ fileSha256: '',
246
+ mediaKey: '',
247
+ fileEncSha256: '',
248
+ directPath: '',
249
+ mediaKeyTimestamp: unixTimestampSeconds(),
250
+ mimetype: 'image/jpeg'
251
+ }
252
+ });
253
+ }
254
+ break;
255
+ }
256
+ case RichSubMessageType.LATEX:
257
+ const expressions = submessage.latexMetadata.expressions;
258
+ for (let n = 0; n < expressions.length; n++) {
259
+ const expression = expressions[n];
260
+ mediaDetailsMetadataList.push({
261
+ id: randomBytes(32).toString('hex'),
262
+ previewMedia: {
263
+ fileSha256: '',
264
+ mediaKey: '',
265
+ fileEncSha256: '',
266
+ directPath: '',
267
+ mediaKeyTimestamp: unixTimestampSeconds(),
268
+ mimetype: 'image/jpeg'
269
+ }
270
+ });
271
+ }
272
+ break;
273
+ }
274
+ }
275
+ return { sources, mediaDetailsMetadataList };
276
+ }
277
+ const richMenuToolId = () => randomBytes(8).toString('hex');
278
+
279
+ const mediaPrimitive = (image, inline = false, padding = 4) => {
280
+ if (!image?.url) return null;
281
+ const media = {
282
+ __typename: 'GenAIMediaItem',
283
+ mime_type: image.mime_type || image.mimeType || 'image/png',
284
+ url: image.url,
285
+ url_fallback: image.url,
286
+ width: image.width || (inline ? 500 : undefined),
287
+ height: image.height || (inline ? 500 : undefined),
288
+ expiration_timestamp_ms: Date.now() + 86400000,
289
+ };
290
+ if (inline) {
291
+ return {
292
+ __typename: 'GenAIMarkdownTextUXPrimitive',
293
+ text: '{{header}}.{{/header}}',
294
+ inline_entities: [{
295
+ __typename: 'GenAITextInlineEntity',
296
+ key: 'header',
297
+ metadata: {
298
+ __typename: 'GenAILatexItem',
299
+ latex_expression: '.',
300
+ font_height: 24,
301
+ padding,
302
+ latex_image: media,
303
+ },
304
+ }],
305
+ };
306
+ }
307
+ return {
308
+ __typename: 'GenAIImagePrimitive',
309
+ preview_image: media,
310
+ full_image: media,
311
+ };
312
+ };
313
+
314
+ const richMenuButton = (button, toast = '') => {
315
+ const label = typeof button === 'string' ? button : (button?.text || button?.label || button?.id || 'Option');
316
+ return {
317
+ label: String(label),
318
+ state: 'PENDING',
319
+ kind: 'OTHER',
320
+ // Preserve supplied IDs so WhatsApp CTA replies are routable.
321
+ // Legacy string-only buttons retain generated IDs for compatibility.
322
+ tool_call_id: typeof button === 'object' && button?.id != null
323
+ ? String(button.id)
324
+ : richMenuToolId(),
325
+ toast: {
326
+ label: typeof button === 'object' && button?.toast != null ? String(button.toast) : String(toast || ''),
327
+ __typename: 'GenAIExtWidgetToast',
328
+ },
329
+ __typename: 'GenAI3PExtWidgetCTA',
330
+ };
331
+ };
332
+
333
+ /**
334
+ * Builds the Meta AI-style rich menu envelope used by vansnowi/baileys.
335
+ * This is an experimental WhatsApp rich-response format, not a standard
336
+ * buttonsMessage/nativeFlowMessage payload.
337
+ */
338
+ export const prepareRichMenuMessage = (content = {}) => {
339
+ const { header = {}, body = {}, footer = {} } = content || {};
340
+ const sections = [];
341
+ const title = header?.title || '';
342
+ if (title) {
343
+ sections.push({
344
+ __typename: 'GenAIUnifiedResponseSection',
345
+ view_model: {
346
+ __typename: 'GenAISingleLayoutViewModel',
347
+ primitive: { __typename: 'FOATextPrimitive', text: '# ' + title },
348
+ },
349
+ });
350
+ }
351
+ const headerImage = mediaPrimitive(header?.image, Boolean(header?.image?.inline));
352
+ if (headerImage) {
353
+ sections.push({
354
+ __typename: 'GenAIUnifiedResponseSection',
355
+ view_model: { __typename: 'GenAISingleLayoutViewModel', primitive: headerImage },
356
+ });
357
+ }
358
+ if (header?.disclaimer) {
359
+ sections.push({
360
+ __typename: 'GenAIUnifiedResponseSection',
361
+ view_model: {
362
+ __typename: 'GenAISingleLayoutViewModel',
363
+ primitive: { __typename: 'GenAIMarkdownTextUXPrimitive', text: header.disclaimerText || ' ' },
364
+ },
365
+ });
366
+ }
367
+ const cards = Array.isArray(body?.cards) ? body.cards : [];
368
+ const buttons = Array.isArray(body?.buttons) ? body.buttons : [];
369
+ if (cards.length) {
370
+ sections.push({
371
+ __typename: 'GenAIUnifiedResponseSection',
372
+ view_model: {
373
+ primitives: cards.map(card => ({
374
+ __typename: 'GenAI3PExtWidgetPrimitive',
375
+ header: { __typename: 'GenAI3PExtWidgetStandardHeader', title: card?.title || '' },
376
+ body: {
377
+ __typename: 'GenAI3PExtCalendarEventList',
378
+ ctas: (Array.isArray(card?.buttons) ? card.buttons : []).map(button => richMenuButton(button, card?.toast)),
379
+ sections: [],
380
+ },
381
+ })),
382
+ __typename: body.carousel ? 'GenAIHScrollLayoutViewModel' : 'GenAIActionRowLayoutViewModel',
383
+ },
384
+ });
385
+ } else if (buttons.length) {
386
+ sections.push({
387
+ __typename: 'GenAIUnifiedResponseSection',
388
+ view_model: {
389
+ __typename: 'GenAISingleLayoutViewModel',
390
+ primitive: {
391
+ __typename: 'GenAI3PExtWidgetPrimitive',
392
+ header: { __typename: 'GenAI3PExtWidgetStandardHeader', title: body.title || '' },
393
+ body: {
394
+ __typename: 'GenAI3PExtCalendarEventList',
395
+ ctas: buttons.map(button => richMenuButton(button, body.toast)),
396
+ sections: [],
397
+ },
398
+ },
399
+ },
400
+ });
401
+ }
402
+ if (footer?.text || footer?.url || footer?.image?.url) {
403
+ const footerImage = mediaPrimitive(footer.image, true, -5);
404
+ sections.push({
405
+ view_model: {
406
+ primitives: [
407
+ { __typename: 'GenAIFooterActionPrimitive', cta_text: footer.text || 'Open', cta_type: 'OPEN_URL', cta_url: footer.url || '' },
408
+ ...(footerImage ? [footerImage] : []),
409
+ ],
410
+ __typename: 'GenAIActionRowLayoutViewModel',
411
+ },
412
+ });
413
+ }
414
+ const unified = { response_id: randomUUID(), sections };
415
+ const richResponseMessage = proto.AIRichResponseMessage.create({
416
+ submessages: [],
417
+ messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
418
+ unifiedResponse: { data: Buffer.from(JSON.stringify(unified)) },
419
+ contextInfo: { isForwarded: true, forwardingScore: 1, forwardOrigin: 4 },
420
+ });
421
+ return wrapToBotForwardedMessage(richResponseMessage);
422
+ };
423
+
424
+ /**
425
+ * Builds a GenAI copy-to-clipboard rich response message.
426
+ * Renders a text label with a dark circular copy icon (addon_action_type: COPY_TO_CLIPBOARD).
427
+ *
428
+ * @param {Object} options
429
+ * @param {string} options.text - The text to display (and copy when tapped)
430
+ * @param {string} [options.label] - Optional display label (defaults to text)
431
+ * @param {'END'|'START'|'CENTER'} [options.alignment='END'] - Button alignment
432
+ * @returns {Object} Wrapped botForwardedMessage ready for relayMessage
433
+ */
434
+ export const prepareCopyToClipboardMessage = (options = {}) => {
435
+ const { text = '', label, alignment = 'END' } = options;
436
+ const displayText = label || text;
437
+ const sections = [
438
+ {
439
+ __typename: 'GenAIUnifiedResponseSection',
440
+ view_model: {
441
+ __typename: 'GenAIAddonActionLayoutViewModel',
442
+ addon_action_type: 'COPY_TO_CLIPBOARD',
443
+ addon_action_alignment: alignment,
444
+ primitives: [
445
+ {
446
+ __typename: 'GenAIMarkdownTextUXPrimitive',
447
+ text: String(displayText),
448
+ inline_entities: [],
449
+ },
450
+ ],
451
+ },
452
+ },
453
+ ];
454
+ const unified = { response_id: randomUUID(), sections };
455
+ const richResponseMessage = proto.AIRichResponseMessage.create({
456
+ submessages: [],
457
+ messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
458
+ unifiedResponse: { data: Buffer.from(JSON.stringify(unified)) },
459
+ contextInfo: { isForwarded: true, forwardingScore: 1, forwardOrigin: 4 },
460
+ });
461
+ return wrapToBotForwardedMessage(richResponseMessage);
462
+ };
463
+
464
+ /**
465
+ * Builds a GenAI rich text message — plain text rendered inside a forwarded rich response.
466
+ * Uses GenAIMarkdownTextUXPrimitive inside a GenAISingleLayoutViewModel.
467
+ *
468
+ * @param {Object} options
469
+ * @param {string} options.text - The text content to display
470
+ * @returns {Object} Wrapped botForwardedMessage ready for relayMessage
471
+ */
472
+ export const prepareRichTextMessage = (options = {}) => {
473
+ const { text = '' } = options;
474
+ const sections = [
475
+ {
476
+ __typename: 'GenAIUnifiedResponseSection',
477
+ view_model: {
478
+ __typename: 'GenAISingleLayoutViewModel',
479
+ primitive: {
480
+ __typename: 'GenAIMarkdownTextUXPrimitive',
481
+ text: String(text),
482
+ inline_entities: [],
483
+ },
484
+ },
485
+ },
486
+ ];
487
+ const unified = { response_id: randomUUID(), sections };
488
+ const richResponseMessage = proto.AIRichResponseMessage.create({
489
+ submessages: [],
490
+ messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
491
+ unifiedResponse: { data: Buffer.from(JSON.stringify(unified)) },
492
+ contextInfo: { isForwarded: true, forwardingScore: 1, forwardOrigin: 4 },
493
+ });
494
+ return wrapToBotForwardedMessage(richResponseMessage);
495
+ };
496
+
497
+ /**
498
+ * Builds a GenAI rich image message — an image rendered inside a forwarded rich response.
499
+ * Uses GenAIImagePrimitive with preview and full image variants.
500
+ *
501
+ * @param {Object} options
502
+ * @param {string} options.url - Image URL
503
+ * @param {string} [options.mimeType='image/png'] - MIME type
504
+ * @returns {Object} Wrapped botForwardedMessage ready for relayMessage
505
+ */
506
+ export const prepareRichImageMessage = (options = {}) => {
507
+ const { url = '', mimeType = 'image/png' } = options;
508
+ const media = {
509
+ __typename: 'GenAIMediaItem',
510
+ mime_type: mimeType,
511
+ url,
512
+ url_fallback: url,
513
+ };
514
+ const sections = [
515
+ {
516
+ __typename: 'GenAIUnifiedResponseSection',
517
+ view_model: {
518
+ __typename: 'GenAISingleLayoutViewModel',
519
+ primitive: {
520
+ __typename: 'GenAIImagePrimitive',
521
+ preview_image: media,
522
+ full_image: media,
523
+ },
524
+ },
525
+ },
526
+ ];
527
+ const unified = { response_id: randomUUID(), sections };
528
+ const richResponseMessage = proto.AIRichResponseMessage.create({
529
+ submessages: [],
530
+ messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
531
+ unifiedResponse: { data: Buffer.from(JSON.stringify(unified)) },
532
+ contextInfo: { isForwarded: true, forwardingScore: 1, forwardOrigin: 4 },
533
+ });
534
+ return wrapToBotForwardedMessage(richResponseMessage);
535
+ };
536
+
537
+
538
+ /**
539
+ * Builds a GenAI rich link message — inline hyperlinks rendered inside a forwarded rich response.
540
+ * Uses GenAIInlineLinkItem for simple clickable text links (not citation-style).
541
+ *
542
+ * @param {Object} options
543
+ * @param {Array<Object>} options.links - Array of { text, url, displayName?, isTrusted? }
544
+ * @returns {Object} Wrapped botForwardedMessage ready for relayMessage
545
+ */
546
+ export const prepareRichLinkMessage = (options = {}) => {
547
+ const { links = [], text: fallbackText } = options;
548
+ const sections = [];
549
+ const allInlineEntities = [];
550
+ let combinedText = '';
551
+
552
+ links.forEach((link, index) => {
553
+ const key = `INLINE_HYPERLINK_${index}`;
554
+ const displayText = link.text || link.displayName || link.url || '';
555
+ const url = link.url || '';
556
+ const isTrusted = link.isTrusted !== false;
557
+
558
+ combinedText += `{{${key}}}${displayText}{{/${key}}}`;
559
+ allInlineEntities.push({
560
+ key,
561
+ metadata: {
562
+ display_name: displayText,
563
+ is_trusted: isTrusted,
564
+ url,
565
+ __typename: 'GenAIInlineLinkItem',
566
+ },
567
+ });
568
+ });
569
+
570
+ sections.push({
571
+ __typename: 'GenAIUnifiedResponseSection',
572
+ view_model: {
573
+ __typename: 'GenAISingleLayoutViewModel',
574
+ primitive: {
575
+ __typename: 'GenAIMarkdownTextUXPrimitive',
576
+ text: combinedText || fallbackText || '',
577
+ inline_entities: allInlineEntities,
578
+ },
579
+ },
580
+ });
581
+ if (sections.length === 0) {
582
+ sections.push({
583
+ __typename: 'GenAIUnifiedResponseSection',
584
+ view_model: {
585
+ __typename: 'GenAISingleLayoutViewModel',
586
+ primitive: {
587
+ __typename: 'GenAIMarkdownTextUXPrimitive',
588
+ text: '',
589
+ inline_entities: [],
590
+ },
591
+ },
592
+ });
593
+ }
594
+ const unified = { response_id: randomUUID(), sections };
595
+ const richResponseMessage = proto.AIRichResponseMessage.create({
596
+ submessages: [],
597
+ messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
598
+ unifiedResponse: { data: Buffer.from(JSON.stringify(unified)) },
599
+ contextInfo: { isForwarded: true, forwardingScore: 1, forwardOrigin: 4 },
600
+ });
601
+ return wrapToBotForwardedMessage(richResponseMessage);
602
+ };
603
+
604
+ export const prepareRichResponseMessage = (content) => {
605
+ const { alignment, code, contentText, disclaimerText, footerText, headerText, imageText, inlineImage, inlineVideo, items, language, latex, links, noDonation, noHeading, posts, products, reels, sources: sourceInputs, suggested, richResponse, table, tapLinkUrl, title } = content;
606
+ let submessages = [];
607
+ if (Array.isArray(richResponse)) {
608
+ submessages = richResponse.map((submessage) => {
609
+ if (submessage.text) {
610
+ return {
611
+ messageType: RichSubMessageType.TEXT,
612
+ messageText: submessage.text,
613
+ inlineEntities: submessage.inlineEntities
614
+ };
615
+ }
616
+ else if (submessage.code) {
617
+ return {
618
+ messageType: RichSubMessageType.CODE,
619
+ codeMetadata: {
620
+ codeLanguage: submessage.language,
621
+ codeBlocks: submessage.code
622
+ }
623
+ };
624
+ }
625
+ else if (submessage.items) {
626
+ return {
627
+ messageType: RichSubMessageType.CONTENT_ITEMS,
628
+ contentItemsMetadata: {
629
+ itemsMetadata: submessage.items,
630
+ contentType: proto.AIRichResponseContentItemsMetadata.ContentType.CAROUSEL
631
+ }
632
+ };
633
+ }
634
+ else if (submessage.inlineImage) {
635
+ return {
636
+ messageType: RichSubMessageType.INLINE_IMAGE,
637
+ imageMetadata: {
638
+ imageUrl: submessage.inlineImage,
639
+ imageText: submessage.imageText,
640
+ alignment: submessage.alignment,
641
+ tapLinkUrl: submessage.tapLinkUrl
642
+ }
643
+ };
644
+ }
645
+ else if (submessage.inlineVideo) {
646
+ return {
647
+ messageType: RichSubMessageType.TEXT,
648
+ messageText: 'INLINE_VIDEO'
649
+ };
650
+ }
651
+ else if (submessage.latex) {
652
+ return {
653
+ messageType: RichSubMessageType.LATEX,
654
+ latexMetadata: {
655
+ text: submessage.text,
656
+ expressions: submessage.latex
657
+ }
658
+ };
659
+ }
660
+ else if (submessage.posts) {
661
+ return {
662
+ messageType: RichSubMessageType.TEXT,
663
+ messageText: 'POSTS'
664
+ };
665
+ }
666
+ else if (submessage.products) {
667
+ return {
668
+ messageType: RichSubMessageType.TEXT,
669
+ messageText: 'PRODUCTS'
670
+ };
671
+ }
672
+ else if (submessage.suggested) {
673
+ return {
674
+ messageType: RichSubMessageType.TEXT,
675
+ messageText: 'SUGGESTED_PROMPT'
676
+ };
677
+ }
678
+ else if (submessage.table) {
679
+ return {
680
+ messageType: RichSubMessageType.TABLE,
681
+ tableMetadata: {
682
+ title: submessage.title,
683
+ rows: submessage.table
684
+ }
685
+ };
686
+ }
687
+ return submessage;
688
+ });
689
+ }
690
+ else {
691
+ if (headerText) {
692
+ submessages.push({
693
+ messageType: RichSubMessageType.TEXT,
694
+ messageText: headerText
695
+ });
696
+ }
697
+ if (contentText) {
698
+ submessages.push({
699
+ messageType: RichSubMessageType.TEXT,
700
+ messageText: contentText
701
+ });
702
+ }
703
+ if (code) {
704
+ language ||= 'javascript';
705
+ submessages.push({
706
+ messageType: RichSubMessageType.CODE,
707
+ codeMetadata: {
708
+ codeLanguage: language,
709
+ codeBlocks: tokenizeCode(code, language)
710
+ }
711
+ });
712
+ }
713
+ const reelItems = Array.isArray(reels) ? reels.map((reel) => ({ reelItem: {
714
+ title: reel?.title || reel?.reels_title || '',
715
+ creator: reel?.creator || '',
716
+ videoUrl: reel?.videoUrl || reel?.reels_url || reel?.url || '',
717
+ thumbnailUrl: reel?.thumbnailUrl || reel?.thumbnail_url || '',
718
+ profileIconUrl: reel?.profileIconUrl || reel?.avatar_url || '',
719
+ likesCount: reel?.likesCount ?? reel?.likes_count ?? 0,
720
+ sharesCount: reel?.sharesCount ?? reel?.shares_count ?? 0,
721
+ viewCount: reel?.viewCount ?? reel?.view_count ?? 0,
722
+ reelSource: reel?.reelSource || reel?.reel_source || 'IG',
723
+ isVerified: !!(reel?.isVerified ?? reel?.is_verified)
724
+ } })) : [];
725
+ const resolvedItems = items || reelItems;
726
+ if (resolvedItems?.length) {
727
+ submessages.push({
728
+ messageType: RichSubMessageType.CONTENT_ITEMS,
729
+ contentItemsMetadata: {
730
+ itemsMetadata: resolvedItems,
731
+ contentType: proto.AIRichResponseContentItemsMetadata.ContentType.CAROUSEL
732
+ }
733
+ });
734
+ }
735
+ if (inlineImage) {
736
+ submessages.push({
737
+ messageType: RichSubMessageType.INLINE_IMAGE,
738
+ imageMetadata: {
739
+ imageUrl: inlineImage,
740
+ imageText,
741
+ alignment,
742
+ tapLinkUrl
743
+ }
744
+ });
745
+ }
746
+ if (inlineVideo) {
747
+ submessages.push({
748
+ messageType: RichSubMessageType.TEXT,
749
+ messageText: 'INLINE_VIDEO'
750
+ });
751
+ }
752
+ if (latex) {
753
+ submessages.push({
754
+ messageType: RichSubMessageType.LATEX,
755
+ latexMetadata: {
756
+ text: contentText || '',
757
+ expressions: latex
758
+ }
759
+ });
760
+ }
761
+ const defaultDonationLink = {
762
+ text: '',
763
+ url: DONATE_URL,
764
+ title: 'PAIR CRYSN⚉VA AI ⩇⩇:⩇⩇',
765
+ displayName: 'pair bot'
766
+ };
767
+ const sourceLinks = (sourceInputs || links || []).map((linkField) => {
768
+ if (typeof linkField === 'string') return { text: '', url: linkField, displayName: linkField };
769
+ return { text: linkField?.text || linkField?.displayName || linkField?.title || '', ...linkField };
770
+ });
771
+ const resolvedLinks = noDonation ? sourceLinks : [...sourceLinks, defaultDonationLink];
772
+ if (resolvedLinks) {
773
+ resolvedLinks.forEach((linkField, index) => {
774
+ const prefix = 'SS_' + index;
775
+ const url = linkField.url || DONATE_URL;
776
+ const sources = linkField.sources?.map((sourceField) => ({
777
+ source_type: 'THIRD_PARTY',
778
+ source_display_name: sourceField.displayName || 'pair bot',
779
+ source_subtitle: sourceField.subtitle || 'crysnovax',
780
+ source_url: sourceField.url || url
781
+ }));
782
+ submessages.push({
783
+ messageType: RichSubMessageType.TEXT,
784
+ messageText: String(linkField.text || '') + ` {{${prefix}}}¹{{/${prefix}}} `,
785
+ inlineEntities: [{
786
+ key: prefix,
787
+ metadata: {
788
+ reference_id: index + 1,
789
+ reference_url: url,
790
+ reference_title: linkField.title || 'Get your own bot',
791
+ reference_display_name: linkField.displayName || 'pair',
792
+ sources: sources || [],
793
+ __typename: 'GenAISearchCitationItem'
794
+ }
795
+ }]
796
+ });
797
+ });
798
+ }
799
+ if (posts) {
800
+ submessages.push({
801
+ messageType: RichSubMessageType.TEXT,
802
+ messageText: 'POSTS'
803
+ });
804
+ }
805
+ if (products) {
806
+ submessages.push({
807
+ messageType: RichSubMessageType.TEXT,
808
+ messageText: 'PRODUCTS'
809
+ });
810
+ }
811
+ if (suggested) {
812
+ submessages.push({
813
+ messageType: RichSubMessageType.TEXT,
814
+ messageText: 'SUGGESTED_PROMPT'
815
+ });
816
+ }
817
+ if (table) {
818
+ submessages.push({
819
+ messageType: RichSubMessageType.TABLE,
820
+ tableMetadata: {
821
+ title,
822
+ rows: table.map((items, index) => ({
823
+ isHeading: !noHeading && index == 0,
824
+ items
825
+ }))
826
+ }
827
+ });
828
+ }
829
+ if (footerText) {
830
+ submessages.push({
831
+ messageType: RichSubMessageType.TEXT,
832
+ messageText: footerText
833
+ });
834
+ }
835
+ }
836
+ const uuid = randomUUID();
837
+ const unified = toUnified(submessages, uuid);
838
+ const richResponseMessage = proto.AIRichResponseMessage.create({
839
+ submessages,
840
+ messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
841
+ unifiedResponse: {
842
+ data: Buffer.from(JSON.stringify(unified)) // Lia@Note 25-04-26 --- Expects "ArrayBufferLike"
843
+ },
844
+ contextInfo: {
845
+ isForwarded: true,
846
+ forwardingScore: 1,
847
+ forwardedAiBotMessageInfo: { botJid: '867051314767696@bot' },
848
+ forwardOrigin: 4
849
+ }
850
+ });
851
+ const message = wrapToBotForwardedMessage(richResponseMessage);
852
+ const botMetadata = message.messageContextInfo.botMetadata;
853
+ // Lia@Note 13-05-26 --- Add disclaimer text on richResponseMessage
854
+ if (disclaimerText) {
855
+ botMetadata.messageDisclaimerText = disclaimerText;
856
+ }
857
+ // Lia@Note 15-05-26 --- Add responseId from unified directly to botMetadata
858
+ botMetadata.botResponseId = uuid;
859
+ // Lia@Note 17-04-26 --- TODO: Fill mediaDetailsMetadataList and sources field
860
+ const { sources, mediaDetailsMetadataList } = buildAdditionalBotMetadataContext(submessages);
861
+ if (sources.length > 0) {
862
+ botMetadata.richResponseSourcesMetadata = { sources };
863
+ }
864
+ if (mediaDetailsMetadataList.length > 0) {
865
+ botMetadata.unifiedResponseMutation = { mediaDetailsMetadataList };
866
+ }
867
+ return message;
868
+ };
869
+ // Lia@Note 17-04-26 --- signature and certificateChain for proofs[] field
870
+ export const botMetadataSignature = () => {
871
+ const signature = new Uint8Array(64);
872
+ getRandomValues(signature);
873
+ return signature;
874
+ };
875
+ export const botMetadataCertificate = (length = 685) => {
876
+ const certificate = new Uint8Array(length);
877
+ certificate[0] = 48;
878
+ certificate[1] = 130;
879
+ getRandomValues(certificate.subarray(2));
880
+ return certificate;
881
+ };
882
+ /**
883
+ * Builds a GenAI HTML primitive message — renders raw HTML inside a forwarded rich response.
884
+ * Uses FOAHtmlPrimitiveDemoDONOTUSE for full HTML rendering inside the chat bubble.
885
+ *
886
+ * This is the game-changer: you can render games, forms, dashboards, and anything
887
+ * else that HTML/CSS/JS can do, directly inside WhatsApp!
888
+ *
889
+ * @param {Object} options
890
+ * @param {string} options.html - Raw HTML string to render
891
+ * @param {Array} [options.trustedSources=[]] - Trusted source URLs for security
892
+ * @returns {Object} Wrapped botForwardedMessage ready for relayMessage
893
+ */
894
+ export const prepareHtmlMessage = (options = {}) => {
895
+ const { html = '', trustedSources = [] } = options;
896
+ const sections = [
897
+ {
898
+ __typename: 'GenAIUnifiedResponseSection',
899
+ view_model: {
900
+ __typename: 'GenAISingleLayoutViewModel',
901
+ primitive: {
902
+ __typename: 'FOAHtmlPrimitiveDemoDONOTUSE',
903
+ trusted_sources: trustedSources,
904
+ payload: String(html).trim()
905
+ }
906
+ }
907
+ }
908
+ ];
909
+ const unified = { response_id: randomUUID(), sections };
910
+ const richResponseMessage = proto.AIRichResponseMessage.create({
911
+ submessages: [],
912
+ messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
913
+ unifiedResponse: { data: Buffer.from(JSON.stringify(unified)) },
914
+ contextInfo: { isForwarded: true, forwardingScore: 1, forwardOrigin: 4 },
915
+ });
916
+ return wrapToBotForwardedMessage(richResponseMessage);
917
+ };
918
+
919
+ export const wrapToBotForwardedMessage = (richResponseMessage) => ({
920
+ messageContextInfo: {
921
+ botMetadata: {
922
+ // Lia@Note 09-04-26 --- TODO: Fill verificationMetadata field
923
+ verificationMetadata: {
924
+ proofs: [
925
+ {
926
+ certificateChain: [
927
+ botMetadataCertificate(),
928
+ botMetadataCertificate(892)
929
+ ],
930
+ version: 1,
931
+ useCase: 1,
932
+ signature: botMetadataSignature()
933
+ }
934
+ ]
935
+ }
936
+ }
937
+ },
938
+ botForwardedMessage: {
939
+ message: { richResponseMessage }
940
+ }
941
+ });
942
+ //# sourceMappingURL=rich-message-utils.js.map