@12-apps/messaging 0.0.0-stage → 1.1.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 (57) hide show
  1. package/ADOPTING.md +119 -0
  2. package/README.md +157 -2
  3. package/dist/channel-Cs_vLGl_.d.ts +293 -0
  4. package/dist/chunk-72TDAQUW.js +136 -0
  5. package/dist/chunk-72TDAQUW.js.map +1 -0
  6. package/dist/chunk-7QVYU63E.js +7 -0
  7. package/dist/chunk-7QVYU63E.js.map +1 -0
  8. package/dist/chunk-R3DKM2IV.js +42 -0
  9. package/dist/chunk-R3DKM2IV.js.map +1 -0
  10. package/dist/chunk-Y7MG2UDQ.js +36 -0
  11. package/dist/chunk-Y7MG2UDQ.js.map +1 -0
  12. package/dist/engine-DTnp2zUL.d.ts +431 -0
  13. package/dist/index.d.ts +97 -0
  14. package/dist/index.js +999 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/manifest/index.d.ts +36 -0
  17. package/dist/manifest/index.js +14 -0
  18. package/dist/manifest/index.js.map +1 -0
  19. package/dist/manifest/server.d.ts +21 -0
  20. package/dist/manifest/server.js +17 -0
  21. package/dist/manifest/server.js.map +1 -0
  22. package/dist/server/index.d.ts +78 -0
  23. package/dist/server/index.js +15 -0
  24. package/dist/server/index.js.map +1 -0
  25. package/dist/whatsapp/index.d.ts +180 -0
  26. package/dist/whatsapp/index.js +385 -0
  27. package/dist/whatsapp/index.js.map +1 -0
  28. package/package.json +90 -4
  29. package/prisma/messaging.prisma +140 -0
  30. package/prisma/migrations/20261114120000_messaging_connector/migration.sql +110 -0
  31. package/src/core/channel.ts +106 -0
  32. package/src/core/connections.ts +67 -0
  33. package/src/core/context.ts +28 -0
  34. package/src/core/engine.ts +64 -0
  35. package/src/core/errors.ts +53 -0
  36. package/src/core/hash.ts +6 -0
  37. package/src/core/inbound.ts +240 -0
  38. package/src/core/inbox.ts +139 -0
  39. package/src/core/memory-store.ts +273 -0
  40. package/src/core/ports.ts +129 -0
  41. package/src/core/prisma-store.ts +354 -0
  42. package/src/core/retention.ts +27 -0
  43. package/src/core/sender.ts +106 -0
  44. package/src/core/store.ts +217 -0
  45. package/src/core/types.ts +189 -0
  46. package/src/index.ts +54 -0
  47. package/src/manifest/index.ts +32 -0
  48. package/src/manifest/server.ts +18 -0
  49. package/src/server/index.ts +22 -0
  50. package/src/server/jobs.ts +99 -0
  51. package/src/server/webhook.ts +92 -0
  52. package/src/whatsapp/graph.ts +136 -0
  53. package/src/whatsapp/index.ts +64 -0
  54. package/src/whatsapp/opt-out.ts +26 -0
  55. package/src/whatsapp/parse.ts +200 -0
  56. package/src/whatsapp/signature.ts +52 -0
  57. package/src/whatsapp/signup.ts +115 -0
@@ -0,0 +1,385 @@
1
+ import {
2
+ ChannelSendFailure,
3
+ serviceWindowPolicy
4
+ } from "../chunk-Y7MG2UDQ.js";
5
+ import {
6
+ __name
7
+ } from "../chunk-7QVYU63E.js";
8
+
9
+ // src/whatsapp/opt-out.ts
10
+ var DEFAULT_OPT_OUT_KEYWORDS = ["PARAR", "SAIR", "STOP", "CANCELAR"];
11
+ function fold(text2) {
12
+ return text2.normalize("NFD").replace(/\p{M}/gu, "").replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, "").toUpperCase();
13
+ }
14
+ __name(fold, "fold");
15
+ function isOptOutText(text2, keywords = DEFAULT_OPT_OUT_KEYWORDS) {
16
+ const folded = fold(text2);
17
+ return folded.length > 0 && keywords.some((keyword) => fold(keyword) === folded);
18
+ }
19
+ __name(isOptOutText, "isOptOutText");
20
+
21
+ // src/whatsapp/parse.ts
22
+ var isObject = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isObject");
23
+ var list = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.filter(isObject) : [], "list");
24
+ var text = /* @__PURE__ */ __name((value) => typeof value === "string" && value.length > 0 ? value : null, "text");
25
+ function when(value) {
26
+ const seconds = typeof value === "string" || typeof value === "number" ? Number(value) : Number.NaN;
27
+ return Number.isFinite(seconds) && seconds > 0 ? new Date(seconds * 1e3) : null;
28
+ }
29
+ __name(when, "when");
30
+ function changes(payload) {
31
+ if (!isObject(payload) || payload.object !== "whatsapp_business_account") return [];
32
+ return list(payload.entry).flatMap((entry) => list(entry.changes)).flatMap((change) => {
33
+ const value = change.value;
34
+ const accountId = isObject(value) && isObject(value.metadata) ? text(value.metadata.phone_number_id) : null;
35
+ return isObject(value) && accountId ? [{ value, accountId }] : [];
36
+ });
37
+ }
38
+ __name(changes, "changes");
39
+ var CONTENT_READERS = {
40
+ text: /* @__PURE__ */ __name((message) => {
41
+ const body = isObject(message.text) ? text(message.text.body) : null;
42
+ return body ? { kind: "TEXT", text: body } : null;
43
+ }, "text"),
44
+ interactive: /* @__PURE__ */ __name((message) => {
45
+ const interactive = isObject(message.interactive) ? message.interactive : {};
46
+ const reply = interactive.button_reply ?? interactive.list_reply;
47
+ const id = isObject(reply) ? text(reply.id) : null;
48
+ return isObject(reply) && id ? { kind: "INTERACTIVE", replyId: id, title: text(reply.title) ?? "" } : null;
49
+ }, "interactive"),
50
+ // A quick-reply button on a template message.
51
+ button: /* @__PURE__ */ __name((message) => {
52
+ if (!isObject(message.button)) return null;
53
+ const title = text(message.button.text) ?? "";
54
+ return { kind: "INTERACTIVE", replyId: text(message.button.payload) ?? title, title };
55
+ }, "button"),
56
+ audio: /* @__PURE__ */ __name((message) => {
57
+ const id = isObject(message.audio) ? text(message.audio.id) : null;
58
+ return isObject(message.audio) && id ? { kind: "AUDIO", mediaId: id, mimeType: text(message.audio.mime_type) } : null;
59
+ }, "audio")
60
+ };
61
+ function contentOf(message) {
62
+ const type = text(message.type) ?? "unknown";
63
+ return CONTENT_READERS[type]?.(message) ?? { kind: "OTHER", channelType: type };
64
+ }
65
+ __name(contentOf, "contentOf");
66
+ function wordsOf(content) {
67
+ if (content.kind === "TEXT") return content.text;
68
+ if (content.kind === "INTERACTIVE") return content.title;
69
+ return null;
70
+ }
71
+ __name(wordsOf, "wordsOf");
72
+ function contactNames(value) {
73
+ const names = /* @__PURE__ */ new Map();
74
+ for (const contact of list(value.contacts)) {
75
+ const waId = text(contact.wa_id);
76
+ const name = isObject(contact.profile) ? text(contact.profile.name) : null;
77
+ if (waId && name) names.set(waId, name);
78
+ }
79
+ return names;
80
+ }
81
+ __name(contactNames, "contactNames");
82
+ function messageEvent(message, accountId, names, keywords) {
83
+ const contactId = text(message.from);
84
+ const externalId = text(message.id);
85
+ const sentAt = when(message.timestamp);
86
+ if (!contactId || !externalId || !sentAt) return null;
87
+ const content = contentOf(message);
88
+ const words = wordsOf(content);
89
+ return {
90
+ type: "message",
91
+ accountId,
92
+ contactId,
93
+ contactName: names.get(contactId) ?? null,
94
+ externalId,
95
+ sentAt,
96
+ content,
97
+ optOut: words !== null && isOptOutText(words, keywords)
98
+ };
99
+ }
100
+ __name(messageEvent, "messageEvent");
101
+ function messageEvents(value, accountId, keywords) {
102
+ const names = contactNames(value);
103
+ return list(value.messages).flatMap((message) => messageEvent(message, accountId, names, keywords) ?? []);
104
+ }
105
+ __name(messageEvents, "messageEvents");
106
+ var RECEIPTS = {
107
+ sent: "SENT",
108
+ delivered: "DELIVERED",
109
+ read: "READ",
110
+ failed: "FAILED"
111
+ };
112
+ function errorOf(status) {
113
+ const [first] = list(status.errors);
114
+ if (!first) return null;
115
+ const code = first.code === void 0 ? "" : String(first.code);
116
+ const title = text(first.title) ?? text(first.message) ?? "";
117
+ return [code, title].filter(Boolean).join(": ") || null;
118
+ }
119
+ __name(errorOf, "errorOf");
120
+ function statusEvents(value, accountId) {
121
+ const out = [];
122
+ for (const status of list(value.statuses)) {
123
+ const externalId = text(status.id);
124
+ const receipt = RECEIPTS[text(status.status) ?? ""];
125
+ const at = when(status.timestamp);
126
+ if (!externalId || !receipt || !at) continue;
127
+ out.push({
128
+ type: "status",
129
+ accountId,
130
+ externalId,
131
+ status: receipt,
132
+ at,
133
+ contactId: text(status.recipient_id),
134
+ error: receipt === "FAILED" ? errorOf(status) : null
135
+ });
136
+ }
137
+ return out;
138
+ }
139
+ __name(statusEvents, "statusEvents");
140
+ function preferenceEvents(value, accountId) {
141
+ const out = [];
142
+ for (const preference of list(value.user_preferences)) {
143
+ const contactId = text(preference.wa_id);
144
+ const at = when(preference.timestamp);
145
+ if (contactId && at && text(preference.value)?.toLowerCase() === "stop") {
146
+ out.push({ type: "opt_out", accountId, contactId, at });
147
+ }
148
+ }
149
+ return out;
150
+ }
151
+ __name(preferenceEvents, "preferenceEvents");
152
+ function parseWhatsAppPayload(payload, options = {}) {
153
+ const keywords = options.optOutKeywords ?? DEFAULT_OPT_OUT_KEYWORDS;
154
+ const out = [];
155
+ for (const { value, accountId } of changes(payload)) {
156
+ out.push(...messageEvents(value, accountId, keywords), ...statusEvents(value, accountId), ...preferenceEvents(value, accountId));
157
+ }
158
+ return out;
159
+ }
160
+ __name(parseWhatsAppPayload, "parseWhatsAppPayload");
161
+ function parseWhatsAppStatuses(payload) {
162
+ return changes(payload).flatMap(({ value, accountId }) => statusEvents(value, accountId));
163
+ }
164
+ __name(parseWhatsAppStatuses, "parseWhatsAppStatuses");
165
+
166
+ // src/whatsapp/graph.ts
167
+ var GraphError = class extends ChannelSendFailure {
168
+ static {
169
+ __name(this, "GraphError");
170
+ }
171
+ status;
172
+ constructor(status, code, message) {
173
+ super(code, message);
174
+ this.name = "GraphError";
175
+ this.status = status;
176
+ }
177
+ };
178
+ function trimTrailingSlashes(value) {
179
+ let end = value.length;
180
+ while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1;
181
+ return end === value.length ? value : value.slice(0, end);
182
+ }
183
+ __name(trimTrailingSlashes, "trimTrailingSlashes");
184
+ function requestOf(graph, call) {
185
+ const base = trimTrailingSlashes(graph.baseUrl);
186
+ const query = call.query ? `?${new URLSearchParams(call.query).toString()}` : "";
187
+ const headers = { accept: "application/json" };
188
+ if (call.token) headers.authorization = `Bearer ${call.token}`;
189
+ if (call.body !== void 0) headers["content-type"] = "application/json";
190
+ return {
191
+ url: `${base}/${graph.apiVersion}/${call.path}${query}`,
192
+ init: { method: call.method, headers, ...call.body !== void 0 ? { body: JSON.stringify(call.body) } : {} }
193
+ };
194
+ }
195
+ __name(requestOf, "requestOf");
196
+ function objectOf(raw) {
197
+ try {
198
+ const parsed = raw ? JSON.parse(raw) : {};
199
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
200
+ } catch {
201
+ return {};
202
+ }
203
+ }
204
+ __name(objectOf, "objectOf");
205
+ function graphErrorOf(status, json) {
206
+ const error = typeof json.error === "object" && json.error !== null ? json.error : {};
207
+ const code = error.code === void 0 ? `HTTP_${status}` : String(error.code);
208
+ const message = typeof error.message === "string" ? error.message : `Graph answered ${status}`;
209
+ return new GraphError(status, code, message.slice(0, 300));
210
+ }
211
+ __name(graphErrorOf, "graphErrorOf");
212
+ async function graphRequest(graph, call) {
213
+ const { url, init } = requestOf(graph, call);
214
+ const response = await graph.fetch(url, init);
215
+ const json = objectOf(await response.text());
216
+ if (response.status < 200 || response.status >= 300) throw graphErrorOf(response.status, json);
217
+ return json;
218
+ }
219
+ __name(graphRequest, "graphRequest");
220
+ function messageBody(to, content) {
221
+ const base = { messaging_product: "whatsapp", recipient_type: "individual", to };
222
+ if (content.kind === "TEXT") return { ...base, type: "text", text: { body: content.text, preview_url: false } };
223
+ if (content.kind === "BUTTONS") {
224
+ return {
225
+ ...base,
226
+ type: "interactive",
227
+ interactive: {
228
+ type: "button",
229
+ body: { text: content.text },
230
+ action: { buttons: content.buttons.map((button) => ({ type: "reply", reply: { id: button.id, title: button.title } })) }
231
+ }
232
+ };
233
+ }
234
+ return {
235
+ ...base,
236
+ type: "interactive",
237
+ interactive: {
238
+ type: "list",
239
+ body: { text: content.text },
240
+ action: {
241
+ button: content.buttonLabel,
242
+ sections: content.sections.map((section) => ({
243
+ ...section.title ? { title: section.title } : {},
244
+ rows: section.rows.map((row) => ({ id: row.id, title: row.title, ...row.description ? { description: row.description } : {} }))
245
+ }))
246
+ }
247
+ }
248
+ };
249
+ }
250
+ __name(messageBody, "messageBody");
251
+ async function sendWhatsAppMessage(graph, input) {
252
+ const json = await graphRequest(graph, {
253
+ method: "POST",
254
+ path: `${encodeURIComponent(input.phoneNumberId)}/messages`,
255
+ token: input.token,
256
+ body: messageBody(input.to, input.content)
257
+ });
258
+ const [first] = Array.isArray(json.messages) ? json.messages : [];
259
+ const id = first && typeof first.id === "string" ? first.id : null;
260
+ if (!id) throw new GraphError(200, "NO_MESSAGE_ID", "Graph accepted the message but returned no id");
261
+ return { externalId: id };
262
+ }
263
+ __name(sendWhatsAppMessage, "sendWhatsAppMessage");
264
+
265
+ // src/whatsapp/signature.ts
266
+ import { createHash, createHmac, timingSafeEqual } from "crypto";
267
+ var META_SIGNATURE_HEADER = "x-hub-signature-256";
268
+ var SIGNATURE = /^sha256=([0-9a-f]{64})$/i;
269
+ function verifyMetaSignature(rawBody, signatureHeader, appSecret) {
270
+ if (!appSecret || !signatureHeader) return false;
271
+ const match = SIGNATURE.exec(signatureHeader.trim());
272
+ if (!match) return false;
273
+ const expected = createHmac("sha256", appSecret).update(rawBody).digest();
274
+ const given = Buffer.from(match[1], "hex");
275
+ return given.length === expected.length && timingSafeEqual(given, expected);
276
+ }
277
+ __name(verifyMetaSignature, "verifyMetaSignature");
278
+ function verifyMetaSubscription(query, verifyToken) {
279
+ const mode = query["hub.mode"];
280
+ const token = query["hub.verify_token"];
281
+ const challenge = query["hub.challenge"];
282
+ if (!verifyToken || mode !== "subscribe" || !token || !challenge) return { ok: false };
283
+ const digest = /* @__PURE__ */ __name((value) => createHash("sha256").update(value, "utf8").digest(), "digest");
284
+ return timingSafeEqual(digest(token), digest(verifyToken)) ? { ok: true, challenge } : { ok: false };
285
+ }
286
+ __name(verifyMetaSubscription, "verifyMetaSubscription");
287
+
288
+ // src/whatsapp/signup.ts
289
+ async function exchangeSignupCode(graph, input) {
290
+ const json = await graphRequest(graph, {
291
+ method: "GET",
292
+ path: "oauth/access_token",
293
+ query: {
294
+ client_id: input.appId,
295
+ client_secret: input.appSecret,
296
+ code: input.code,
297
+ ...input.redirectUri ? { redirect_uri: input.redirectUri } : {}
298
+ }
299
+ });
300
+ if (typeof json.access_token !== "string" || json.access_token.length === 0) {
301
+ throw new GraphError(200, "NO_ACCESS_TOKEN", "Graph answered the code exchange without a token");
302
+ }
303
+ return { accessToken: json.access_token };
304
+ }
305
+ __name(exchangeSignupCode, "exchangeSignupCode");
306
+ async function readSignupAccounts(graph, input) {
307
+ const debug = await graphRequest(graph, {
308
+ method: "GET",
309
+ path: "debug_token",
310
+ query: { input_token: input.accessToken },
311
+ token: `${input.appId}|${input.appSecret}`
312
+ });
313
+ const data = typeof debug.data === "object" && debug.data !== null ? debug.data : {};
314
+ const scopes = Array.isArray(data.granular_scopes) ? data.granular_scopes : [];
315
+ const wabaIds = new Set(
316
+ scopes.filter((scope) => scope.scope === "whatsapp_business_management" && Array.isArray(scope.target_ids)).flatMap((scope) => scope.target_ids.filter((id) => typeof id === "string"))
317
+ );
318
+ const accounts = [];
319
+ for (const wabaId of wabaIds) {
320
+ accounts.push({ wabaId, phoneNumbers: await readPhoneNumbers(graph, wabaId, input.accessToken) });
321
+ }
322
+ return accounts;
323
+ }
324
+ __name(readSignupAccounts, "readSignupAccounts");
325
+ async function readPhoneNumbers(graph, wabaId, accessToken) {
326
+ const json = await graphRequest(graph, {
327
+ method: "GET",
328
+ path: `${encodeURIComponent(wabaId)}/phone_numbers`,
329
+ query: { fields: "id,display_phone_number,verified_name" },
330
+ token: accessToken
331
+ });
332
+ const rows = Array.isArray(json.data) ? json.data : [];
333
+ return rows.filter((row) => typeof row.id === "string" && typeof row.display_phone_number === "string").map((row) => ({
334
+ id: row.id,
335
+ displayPhoneNumber: row.display_phone_number,
336
+ verifiedName: typeof row.verified_name === "string" ? row.verified_name : null
337
+ }));
338
+ }
339
+ __name(readPhoneNumbers, "readPhoneNumbers");
340
+ async function subscribeAppToWaba(graph, input) {
341
+ const json = await graphRequest(graph, {
342
+ method: "POST",
343
+ path: `${encodeURIComponent(input.wabaId)}/subscribed_apps`,
344
+ token: input.accessToken
345
+ });
346
+ if (json.success !== true) throw new GraphError(200, "NOT_SUBSCRIBED", "Graph did not confirm the subscription");
347
+ }
348
+ __name(subscribeAppToWaba, "subscribeAppToWaba");
349
+
350
+ // src/whatsapp/index.ts
351
+ var WHATSAPP_CHANNEL = "whatsapp";
352
+ var WHATSAPP_SERVICE_WINDOW_MS = 24 * 60 * 60 * 1e3;
353
+ function createWhatsAppAdapter(config) {
354
+ return {
355
+ kind: WHATSAPP_CHANNEL,
356
+ handshake: /* @__PURE__ */ __name((query) => verifyMetaSubscription(query, config.verifyToken), "handshake"),
357
+ verify: /* @__PURE__ */ __name(({ rawBody, header }) => verifyMetaSignature(rawBody, header(META_SIGNATURE_HEADER), config.appSecret), "verify"),
358
+ parse: /* @__PURE__ */ __name((rawBody) => parseWhatsAppPayload(JSON.parse(rawBody), {
359
+ ...config.optOutKeywords ? { optOutKeywords: config.optOutKeywords } : {}
360
+ }), "parse"),
361
+ send: /* @__PURE__ */ __name(({ credential, accountId, to, content }) => sendWhatsAppMessage(config.graph, { token: credential, phoneNumberId: accountId, to, content }), "send"),
362
+ policy: serviceWindowPolicy(WHATSAPP_SERVICE_WINDOW_MS)
363
+ };
364
+ }
365
+ __name(createWhatsAppAdapter, "createWhatsAppAdapter");
366
+ export {
367
+ DEFAULT_OPT_OUT_KEYWORDS,
368
+ GraphError,
369
+ META_SIGNATURE_HEADER,
370
+ WHATSAPP_CHANNEL,
371
+ WHATSAPP_SERVICE_WINDOW_MS,
372
+ createWhatsAppAdapter,
373
+ exchangeSignupCode,
374
+ graphRequest,
375
+ isOptOutText,
376
+ messageBody,
377
+ parseWhatsAppPayload,
378
+ parseWhatsAppStatuses,
379
+ readSignupAccounts,
380
+ sendWhatsAppMessage,
381
+ subscribeAppToWaba,
382
+ verifyMetaSignature,
383
+ verifyMetaSubscription
384
+ };
385
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/whatsapp/opt-out.ts","../../src/whatsapp/parse.ts","../../src/whatsapp/graph.ts","../../src/whatsapp/signature.ts","../../src/whatsapp/signup.ts","../../src/whatsapp/index.ts"],"sourcesContent":["/**\n * The words that opt a contact out, by default: the Portuguese and English\n * stop words a WhatsApp user is told to send. A host replaces the list through\n * the adapter's config.\n */\nexport const DEFAULT_OPT_OUT_KEYWORDS: readonly string[] = [\"PARAR\", \"SAIR\", \"STOP\", \"CANCELAR\"];\n\n/** Upper case, accents stripped, surrounding space, punctuation and emoji trimmed. */\nfunction fold(text: string): string {\n return text\n .normalize(\"NFD\")\n .replace(/\\p{M}/gu, \"\")\n .replace(/^[^\\p{L}\\p{N}]+|[^\\p{L}\\p{N}]+$/gu, \"\")\n .toUpperCase();\n}\n\n/**\n * Is this text an opt-out? Only when the WHOLE message is one keyword —\n * case- and accent-insensitive, ignoring punctuation and emoji around it — so\n * \"parar\", \"PARAR.\" and \"Parar!\" opt out, and \"parar de enviar\" (a sentence,\n * maybe about something else) does not.\n */\nexport function isOptOutText(text: string, keywords: readonly string[] = DEFAULT_OPT_OUT_KEYWORDS): boolean {\n const folded = fold(text);\n return folded.length > 0 && keywords.some((keyword) => fold(keyword) === folded);\n}\n","import type {\n InboundContent,\n InboundMessageEvent,\n NormalizedEvent,\n OptOutEvent,\n ReceiptStatus,\n StatusEvent,\n} from \"../core/types\";\nimport { DEFAULT_OPT_OUT_KEYWORDS, isOptOutText } from \"./opt-out\";\n\n/**\n * The WhatsApp Cloud API webhook payload, read defensively: every field is\n * checked before it is trusted, an unknown shape is skipped rather than\n * thrown on, and only `JSON.parse` itself may throw (bytes that are not JSON).\n *\n * Shape: `{ object: \"whatsapp_business_account\", entry: [{ id, changes: [{\n * field, value: { metadata: { phone_number_id }, contacts, messages,\n * statuses, user_preferences } }] }] }`. Events come out in payload order.\n */\n\ntype Json = Record<string, unknown>;\n\nconst isObject = (value: unknown): value is Json => typeof value === \"object\" && value !== null && !Array.isArray(value);\nconst list = (value: unknown): Json[] => (Array.isArray(value) ? value.filter(isObject) : []);\nconst text = (value: unknown): string | null => (typeof value === \"string\" && value.length > 0 ? value : null);\n\n/** Meta's timestamps are Unix SECONDS, as a string. Null when absent or malformed. */\nfunction when(value: unknown): Date | null {\n const seconds = typeof value === \"string\" || typeof value === \"number\" ? Number(value) : Number.NaN;\n return Number.isFinite(seconds) && seconds > 0 ? new Date(seconds * 1000) : null;\n}\n\ninterface Change {\n value: Json;\n accountId: string;\n}\n\n/** Every `value` of every change, with the account it was delivered to. */\nfunction changes(payload: unknown): Change[] {\n if (!isObject(payload) || payload.object !== \"whatsapp_business_account\") return [];\n return list(payload.entry)\n .flatMap((entry) => list(entry.changes))\n .flatMap((change): Change[] => {\n const value = change.value;\n const accountId = isObject(value) && isObject(value.metadata) ? text(value.metadata.phone_number_id) : null;\n return isObject(value) && accountId ? [{ value, accountId }] : [];\n });\n}\n\n/** One reader per message `type`; null when the type's object is missing or malformed. */\nconst CONTENT_READERS: Readonly<Record<string, (message: Json) => InboundContent | null>> = {\n text: (message) => {\n const body = isObject(message.text) ? text(message.text.body) : null;\n return body ? { kind: \"TEXT\", text: body } : null;\n },\n interactive: (message) => {\n const interactive = isObject(message.interactive) ? message.interactive : {};\n const reply = interactive.button_reply ?? interactive.list_reply;\n const id = isObject(reply) ? text(reply.id) : null;\n return isObject(reply) && id ? { kind: \"INTERACTIVE\", replyId: id, title: text(reply.title) ?? \"\" } : null;\n },\n // A quick-reply button on a template message.\n button: (message) => {\n if (!isObject(message.button)) return null;\n const title = text(message.button.text) ?? \"\";\n return { kind: \"INTERACTIVE\", replyId: text(message.button.payload) ?? title, title };\n },\n audio: (message) => {\n const id = isObject(message.audio) ? text(message.audio.id) : null;\n return isObject(message.audio) && id ? { kind: \"AUDIO\", mediaId: id, mimeType: text(message.audio.mime_type) } : null;\n },\n};\n\n/** The content of one message, by its `type`; anything unread is OTHER. */\nfunction contentOf(message: Json): InboundContent {\n const type = text(message.type) ?? \"unknown\";\n return CONTENT_READERS[type]?.(message) ?? { kind: \"OTHER\", channelType: type };\n}\n\n/** The words a person typed or tapped, for the opt-out check. */\nfunction wordsOf(content: InboundContent): string | null {\n if (content.kind === \"TEXT\") return content.text;\n if (content.kind === \"INTERACTIVE\") return content.title;\n return null;\n}\n\n/** The profile name Meta sends per sender, keyed by wa_id. */\nfunction contactNames(value: Json): Map<string, string> {\n const names = new Map<string, string>();\n for (const contact of list(value.contacts)) {\n const waId = text(contact.wa_id);\n const name = isObject(contact.profile) ? text(contact.profile.name) : null;\n if (waId && name) names.set(waId, name);\n }\n return names;\n}\n\nfunction messageEvent(\n message: Json,\n accountId: string,\n names: Map<string, string>,\n keywords: readonly string[],\n): InboundMessageEvent | null {\n const contactId = text(message.from);\n const externalId = text(message.id);\n const sentAt = when(message.timestamp);\n if (!contactId || !externalId || !sentAt) return null;\n const content = contentOf(message);\n const words = wordsOf(content);\n return {\n type: \"message\",\n accountId,\n contactId,\n contactName: names.get(contactId) ?? null,\n externalId,\n sentAt,\n content,\n optOut: words !== null && isOptOutText(words, keywords),\n };\n}\n\nfunction messageEvents(value: Json, accountId: string, keywords: readonly string[]): InboundMessageEvent[] {\n const names = contactNames(value);\n return list(value.messages).flatMap((message) => messageEvent(message, accountId, names, keywords) ?? []);\n}\n\nconst RECEIPTS: Readonly<Record<string, ReceiptStatus>> = {\n sent: \"SENT\",\n delivered: \"DELIVERED\",\n read: \"READ\",\n failed: \"FAILED\",\n};\n\n/** The first error of a failed status, as `code: title`. */\nfunction errorOf(status: Json): string | null {\n const [first] = list(status.errors);\n if (!first) return null;\n const code = first.code === undefined ? \"\" : String(first.code);\n const title = text(first.title) ?? text(first.message) ?? \"\";\n return [code, title].filter(Boolean).join(\": \") || null;\n}\n\nfunction statusEvents(value: Json, accountId: string): StatusEvent[] {\n const out: StatusEvent[] = [];\n for (const status of list(value.statuses)) {\n const externalId = text(status.id);\n const receipt = RECEIPTS[text(status.status) ?? \"\"];\n const at = when(status.timestamp);\n if (!externalId || !receipt || !at) continue;\n out.push({\n type: \"status\",\n accountId,\n externalId,\n status: receipt,\n at,\n contactId: text(status.recipient_id),\n error: receipt === \"FAILED\" ? errorOf(status) : null,\n });\n }\n return out;\n}\n\n/** Meta's own opt-out: a `user_preferences` change whose value is `stop`. */\nfunction preferenceEvents(value: Json, accountId: string): OptOutEvent[] {\n const out: OptOutEvent[] = [];\n for (const preference of list(value.user_preferences)) {\n const contactId = text(preference.wa_id);\n const at = when(preference.timestamp);\n if (contactId && at && text(preference.value)?.toLowerCase() === \"stop\") {\n out.push({ type: \"opt_out\", accountId, contactId, at });\n }\n }\n return out;\n}\n\n/**\n * Every event in a WhatsApp webhook payload (already `JSON.parse`d): inbound\n * messages (with the opt-out keyword check), delivery receipts, and Meta's\n * own opt-out signal.\n */\nexport function parseWhatsAppPayload(\n payload: unknown,\n options: { optOutKeywords?: readonly string[] } = {},\n): NormalizedEvent[] {\n const keywords = options.optOutKeywords ?? DEFAULT_OPT_OUT_KEYWORDS;\n const out: NormalizedEvent[] = [];\n for (const { value, accountId } of changes(payload)) {\n out.push(...messageEvents(value, accountId, keywords), ...statusEvents(value, accountId), ...preferenceEvents(value, accountId));\n }\n return out;\n}\n\n/**\n * Only the delivery receipts of a WhatsApp webhook payload — for a host that\n * tracks receipts of messages it sends some other way (a platform\n * notification number) without mounting the connector.\n */\nexport function parseWhatsAppStatuses(payload: unknown): StatusEvent[] {\n return changes(payload).flatMap(({ value, accountId }) => statusEvents(value, accountId));\n}\n","import { ChannelSendFailure } from \"../core/channel\";\nimport type { OutboundContent } from \"../core/types\";\n\n/**\n * The only way the adapter reaches Meta: an injected fetch. The global\n * `fetch` satisfies it; a test answers it with a recording fake.\n */\nexport type FetchPort = (\n url: string,\n init: { method: string; headers: Record<string, string>; body?: string },\n) => Promise<{ status: number; text(): Promise<string> }>;\n\n/** Where the Graph API is, and through what. Both numbers are config, never constants in the adapter. */\nexport interface GraphConfig {\n fetch: FetchPort;\n /** `https://graph.facebook.com` — no trailing slash needed. */\n baseUrl: string;\n /** `v23.0` — the Graph API version every call is pinned to. */\n apiVersion: string;\n}\n\n/** A Graph call that did not answer 2xx. Carries Meta's error code; never the token. */\nexport class GraphError extends ChannelSendFailure {\n readonly status: number;\n constructor(status: number, code: string, message: string) {\n super(code, message);\n this.name = \"GraphError\";\n this.status = status;\n }\n}\n\ntype Json = Record<string, unknown>;\n\ninterface GraphCall {\n method: \"GET\" | \"POST\";\n path: string;\n token?: string;\n query?: Record<string, string>;\n body?: unknown;\n}\n\n/** Drops trailing \"/\" characters in one linear pass (a regex here backtracks quadratically on library input). */\nfunction trimTrailingSlashes(value: string): string {\n let end = value.length;\n while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1;\n return end === value.length ? value : value.slice(0, end);\n}\n\n/** The URL and the request init of one call. The token travels in a header, never in the URL. */\nfunction requestOf(graph: GraphConfig, call: GraphCall) {\n const base = trimTrailingSlashes(graph.baseUrl);\n const query = call.query ? `?${new URLSearchParams(call.query).toString()}` : \"\";\n const headers: Record<string, string> = { accept: \"application/json\" };\n if (call.token) headers.authorization = `Bearer ${call.token}`;\n if (call.body !== undefined) headers[\"content-type\"] = \"application/json\";\n return {\n url: `${base}/${graph.apiVersion}/${call.path}${query}`,\n init: { method: call.method, headers, ...(call.body !== undefined ? { body: JSON.stringify(call.body) } : {}) },\n };\n}\n\n/** A body as a JSON object; anything else (empty, HTML, an array) as `{}`. */\nfunction objectOf(raw: string): Json {\n try {\n const parsed: unknown = raw ? JSON.parse(raw) : {};\n return typeof parsed === \"object\" && parsed !== null && !Array.isArray(parsed) ? (parsed as Json) : {};\n } catch {\n return {};\n }\n}\n\n/** Meta's error envelope (`{ error: { code, message } }`) as a {@link GraphError}. */\nfunction graphErrorOf(status: number, json: Json): GraphError {\n const error = typeof json.error === \"object\" && json.error !== null ? (json.error as Json) : {};\n const code = error.code === undefined ? `HTTP_${status}` : String(error.code);\n const message = typeof error.message === \"string\" ? error.message : `Graph answered ${status}`;\n return new GraphError(status, code, message.slice(0, 300));\n}\n\n/** One Graph call; resolves to the parsed JSON body, or throws {@link GraphError}. */\nexport async function graphRequest(graph: GraphConfig, call: GraphCall): Promise<Json> {\n const { url, init } = requestOf(graph, call);\n const response = await graph.fetch(url, init);\n const json = objectOf(await response.text());\n if (response.status < 200 || response.status >= 300) throw graphErrorOf(response.status, json);\n return json;\n}\n\n/** The Cloud API body for one outbound message. */\nexport function messageBody(to: string, content: OutboundContent): Json {\n const base = { messaging_product: \"whatsapp\", recipient_type: \"individual\", to };\n if (content.kind === \"TEXT\") return { ...base, type: \"text\", text: { body: content.text, preview_url: false } };\n if (content.kind === \"BUTTONS\") {\n return {\n ...base,\n type: \"interactive\",\n interactive: {\n type: \"button\",\n body: { text: content.text },\n action: { buttons: content.buttons.map((button) => ({ type: \"reply\", reply: { id: button.id, title: button.title } })) },\n },\n };\n }\n return {\n ...base,\n type: \"interactive\",\n interactive: {\n type: \"list\",\n body: { text: content.text },\n action: {\n button: content.buttonLabel,\n sections: content.sections.map((section) => ({\n ...(section.title ? { title: section.title } : {}),\n rows: section.rows.map((row) => ({ id: row.id, title: row.title, ...(row.description ? { description: row.description } : {}) })),\n })),\n },\n },\n };\n}\n\n/** Send one message from a phone number; resolves to its wamid. */\nexport async function sendWhatsAppMessage(\n graph: GraphConfig,\n input: { token: string; phoneNumberId: string; to: string; content: OutboundContent },\n): Promise<{ externalId: string }> {\n const json = await graphRequest(graph, {\n method: \"POST\",\n path: `${encodeURIComponent(input.phoneNumberId)}/messages`,\n token: input.token,\n body: messageBody(input.to, input.content),\n });\n const [first] = Array.isArray(json.messages) ? (json.messages as Json[]) : [];\n const id = first && typeof first.id === \"string\" ? first.id : null;\n if (!id) throw new GraphError(200, \"NO_MESSAGE_ID\", \"Graph accepted the message but returned no id\");\n return { externalId: id };\n}\n","import { createHash, createHmac, timingSafeEqual } from \"node:crypto\";\n\n/**\n * Meta's webhook proofs, as standalone functions: the connector's WhatsApp\n * adapter uses them, and so can any other WhatsApp webhook a host runs (a\n * platform notification number's receipts), without mounting the connector.\n */\n\n/** The header Meta signs every webhook POST with. */\nexport const META_SIGNATURE_HEADER = \"x-hub-signature-256\";\n\nconst SIGNATURE = /^sha256=([0-9a-f]{64})$/i;\n\n/**\n * Does `signatureHeader` prove `rawBody` was signed with `appSecret`?\n *\n * HMAC-SHA256 over the RAW body bytes exactly as received (a re-serialized\n * JSON body never matches; hand the bytes, not a decoded string, where the\n * framework gives them), compared in constant time. Fails CLOSED: an empty\n * secret, a missing header, a header in any other shape, or a digest of the\n * wrong length is `false` — never an exception, never `true`.\n */\nexport function verifyMetaSignature(rawBody: string | Uint8Array, signatureHeader: string | null | undefined, appSecret: string): boolean {\n if (!appSecret || !signatureHeader) return false;\n const match = SIGNATURE.exec(signatureHeader.trim());\n if (!match) return false;\n const expected = createHmac(\"sha256\", appSecret).update(rawBody).digest();\n const given = Buffer.from(match[1]!, \"hex\");\n return given.length === expected.length && timingSafeEqual(given, expected);\n}\n\n/** What the subscription handshake answers. */\nexport type MetaHandshake = { ok: true; challenge: string } | { ok: false };\n\n/**\n * Meta's `GET` subscription handshake: `hub.mode=subscribe`, the\n * `hub.verify_token` configured on the app, and a `hub.challenge` to echo.\n * The token is compared in constant time; an empty configured token refuses\n * every handshake.\n */\nexport function verifyMetaSubscription(\n query: Readonly<Record<string, string | undefined>>,\n verifyToken: string,\n): MetaHandshake {\n const mode = query[\"hub.mode\"];\n const token = query[\"hub.verify_token\"];\n const challenge = query[\"hub.challenge\"];\n if (!verifyToken || mode !== \"subscribe\" || !token || !challenge) return { ok: false };\n // Digests of equal length, so the comparison leaks neither content nor length.\n const digest = (value: string) => createHash(\"sha256\").update(value, \"utf8\").digest();\n return timingSafeEqual(digest(token), digest(verifyToken)) ? { ok: true, challenge } : { ok: false };\n}\n","import { GraphError, graphRequest, type GraphConfig } from \"./graph\";\n\n/**\n * Embedded Signup, server half. The browser half (Meta's SDK popup) hands the\n * host a short-lived `code`; these three calls turn it into a connection:\n *\n * 1. {@link exchangeSignupCode} — the code for a business token;\n * 2. {@link readSignupAccounts} — which WhatsApp Business Accounts the token\n * was granted, and each one's phone numbers (id + display number);\n * 3. {@link subscribeAppToWaba} — subscribe the app to the chosen account's\n * webhooks, so its messages reach the connector.\n *\n * Then the host calls `engine.connect(...)` with the phone number id, the\n * display number and the token, which the engine seals. None of these\n * functions logs or returns anything but what is named.\n */\n\ntype Json = Record<string, unknown>;\n\n/** The app's own identity on Meta. The secret is the host's, read where it keeps secrets. */\nexport interface MetaAppCredentials {\n appId: string;\n appSecret: string;\n}\n\n/** Exchange Embedded Signup's code for a business integration token. */\nexport async function exchangeSignupCode(\n graph: GraphConfig,\n input: MetaAppCredentials & { code: string; redirectUri?: string },\n): Promise<{ accessToken: string }> {\n const json = await graphRequest(graph, {\n method: \"GET\",\n path: \"oauth/access_token\",\n query: {\n client_id: input.appId,\n client_secret: input.appSecret,\n code: input.code,\n ...(input.redirectUri ? { redirect_uri: input.redirectUri } : {}),\n },\n });\n if (typeof json.access_token !== \"string\" || json.access_token.length === 0) {\n throw new GraphError(200, \"NO_ACCESS_TOKEN\", \"Graph answered the code exchange without a token\");\n }\n return { accessToken: json.access_token };\n}\n\n/** One phone number of a WhatsApp Business Account. */\nexport interface SignupPhoneNumber {\n /** The phone_number_id: the connection's external account id. */\n id: string;\n /** What a person reads (`+55 11 98765-4321`): the connection's display address. */\n displayPhoneNumber: string;\n verifiedName: string | null;\n}\n\nexport interface SignupAccount {\n /** The WABA id: the connection's external parent id. */\n wabaId: string;\n phoneNumbers: SignupPhoneNumber[];\n}\n\n/**\n * The WhatsApp Business Accounts the token was granted (read from the token's\n * own granular scopes, with the app's token), and each one's phone numbers.\n */\nexport async function readSignupAccounts(\n graph: GraphConfig,\n input: MetaAppCredentials & { accessToken: string },\n): Promise<SignupAccount[]> {\n const debug = await graphRequest(graph, {\n method: \"GET\",\n path: \"debug_token\",\n query: { input_token: input.accessToken },\n token: `${input.appId}|${input.appSecret}`,\n });\n const data = typeof debug.data === \"object\" && debug.data !== null ? (debug.data as Json) : {};\n const scopes = Array.isArray(data.granular_scopes) ? (data.granular_scopes as Json[]) : [];\n const wabaIds = new Set(\n scopes\n .filter((scope) => scope.scope === \"whatsapp_business_management\" && Array.isArray(scope.target_ids))\n .flatMap((scope) => (scope.target_ids as unknown[]).filter((id): id is string => typeof id === \"string\")),\n );\n const accounts: SignupAccount[] = [];\n for (const wabaId of wabaIds) {\n accounts.push({ wabaId, phoneNumbers: await readPhoneNumbers(graph, wabaId, input.accessToken) });\n }\n return accounts;\n}\n\nasync function readPhoneNumbers(graph: GraphConfig, wabaId: string, accessToken: string): Promise<SignupPhoneNumber[]> {\n const json = await graphRequest(graph, {\n method: \"GET\",\n path: `${encodeURIComponent(wabaId)}/phone_numbers`,\n query: { fields: \"id,display_phone_number,verified_name\" },\n token: accessToken,\n });\n const rows = Array.isArray(json.data) ? (json.data as Json[]) : [];\n return rows\n .filter((row) => typeof row.id === \"string\" && typeof row.display_phone_number === \"string\")\n .map((row) => ({\n id: row.id as string,\n displayPhoneNumber: row.display_phone_number as string,\n verifiedName: typeof row.verified_name === \"string\" ? row.verified_name : null,\n }));\n}\n\n/** Subscribe the app to a WABA's webhooks. Resolves when Meta answers `success: true`. */\nexport async function subscribeAppToWaba(graph: GraphConfig, input: { wabaId: string; accessToken: string }): Promise<void> {\n const json = await graphRequest(graph, {\n method: \"POST\",\n path: `${encodeURIComponent(input.wabaId)}/subscribed_apps`,\n token: input.accessToken,\n });\n if (json.success !== true) throw new GraphError(200, \"NOT_SUBSCRIBED\", \"Graph did not confirm the subscription\");\n}\n","/**\n * `@12-apps/messaging/whatsapp` — the WhatsApp Cloud API channel adapter.\n *\n * `createWhatsAppAdapter(config)` is what a host hands the engine. The pieces\n * are exported on their own too: the signature check and the receipt parser\n * serve any WhatsApp webhook (a platform notification number), and the\n * Embedded Signup helpers serve the host's connect flow.\n *\n * `@12-apps/notifications` has its own WhatsApp transport, for one-way\n * notification messages. It is deliberately NOT reused here: this adapter\n * carries a conversation (inbound, the service window, opt-out, receipts),\n * which that transport has no model for.\n */\n\nimport { serviceWindowPolicy, type ChannelAdapter } from \"../core/channel\";\nimport { parseWhatsAppPayload } from \"./parse\";\nimport { sendWhatsAppMessage, type GraphConfig } from \"./graph\";\nimport { META_SIGNATURE_HEADER, verifyMetaSignature, verifyMetaSubscription } from \"./signature\";\n\n/** The channel key every WhatsApp row carries. */\nexport const WHATSAPP_CHANNEL = \"whatsapp\";\n\n/** WhatsApp's customer service window: free-form messages only within 24 h of the contact's last message. */\nexport const WHATSAPP_SERVICE_WINDOW_MS = 24 * 60 * 60 * 1000;\n\nexport interface WhatsAppAdapterConfig {\n /** The Meta app's secret: every webhook POST is signed with it. Empty refuses every delivery. */\n appSecret: string;\n /** The token configured on the app's webhook subscription. Empty refuses every handshake. */\n verifyToken: string;\n /** The Graph API: fetch, base URL and version. */\n graph: GraphConfig;\n /** The whole-message words that opt a contact out. Default: PARAR, SAIR, STOP, CANCELAR. */\n optOutKeywords?: readonly string[];\n}\n\n/** The WhatsApp Cloud adapter. */\nexport function createWhatsAppAdapter(config: WhatsAppAdapterConfig): ChannelAdapter {\n return {\n kind: WHATSAPP_CHANNEL,\n handshake: (query) => verifyMetaSubscription(query, config.verifyToken),\n verify: ({ rawBody, header }) => verifyMetaSignature(rawBody, header(META_SIGNATURE_HEADER), config.appSecret),\n parse: (rawBody) =>\n parseWhatsAppPayload(JSON.parse(rawBody) as unknown, {\n ...(config.optOutKeywords ? { optOutKeywords: config.optOutKeywords } : {}),\n }),\n send: ({ credential, accountId, to, content }) =>\n sendWhatsAppMessage(config.graph, { token: credential, phoneNumberId: accountId, to, content }),\n policy: serviceWindowPolicy(WHATSAPP_SERVICE_WINDOW_MS),\n };\n}\n\nexport { META_SIGNATURE_HEADER, verifyMetaSignature, verifyMetaSubscription, type MetaHandshake } from \"./signature\";\nexport { parseWhatsAppPayload, parseWhatsAppStatuses } from \"./parse\";\nexport { DEFAULT_OPT_OUT_KEYWORDS, isOptOutText } from \"./opt-out\";\nexport { GraphError, graphRequest, messageBody, sendWhatsAppMessage, type FetchPort, type GraphConfig } from \"./graph\";\nexport {\n exchangeSignupCode,\n readSignupAccounts,\n subscribeAppToWaba,\n type MetaAppCredentials,\n type SignupAccount,\n type SignupPhoneNumber,\n} from \"./signup\";\n"],"mappings":";;;;;;;;;AAKO,IAAM,2BAA8C,CAAC,SAAS,QAAQ,QAAQ,UAAU;AAG/F,SAAS,KAAKA,OAAsB;AAClC,SAAOA,MACJ,UAAU,KAAK,EACf,QAAQ,WAAW,EAAE,EACrB,QAAQ,qCAAqC,EAAE,EAC/C,YAAY;AACjB;AANS;AAcF,SAAS,aAAaA,OAAc,WAA8B,0BAAmC;AAC1G,QAAM,SAAS,KAAKA,KAAI;AACxB,SAAO,OAAO,SAAS,KAAK,SAAS,KAAK,CAAC,YAAY,KAAK,OAAO,MAAM,MAAM;AACjF;AAHgB;;;ACAhB,IAAM,WAAW,wBAAC,UAAkC,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,GAAtG;AACjB,IAAM,OAAO,wBAAC,UAA4B,MAAM,QAAQ,KAAK,IAAI,MAAM,OAAO,QAAQ,IAAI,CAAC,GAA9E;AACb,IAAM,OAAO,wBAAC,UAAmC,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ,MAA5F;AAGb,SAAS,KAAK,OAA6B;AACzC,QAAM,UAAU,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW,OAAO,KAAK,IAAI,OAAO;AAChG,SAAO,OAAO,SAAS,OAAO,KAAK,UAAU,IAAI,IAAI,KAAK,UAAU,GAAI,IAAI;AAC9E;AAHS;AAWT,SAAS,QAAQ,SAA4B;AAC3C,MAAI,CAAC,SAAS,OAAO,KAAK,QAAQ,WAAW,4BAA6B,QAAO,CAAC;AAClF,SAAO,KAAK,QAAQ,KAAK,EACtB,QAAQ,CAAC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,QAAQ,oBAAoB,0BAA0B;AAAA,EACxD;AACF;AAbgB;","names":["text"]}
package/package.json CHANGED
@@ -1,6 +1,92 @@
1
1
  {
2
2
  "name": "@12-apps/messaging",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "description": "A channel-agnostic conversational messaging connector: channel connections with sealed credentials, a durable inbox of raw webhook deliveries, conversations with an owner state and a structured summary, messages with delivery statuses, an opt-out, a per-channel send policy and a text-retention sweep, behind a channel adapter port. WhatsApp Cloud is the first adapter (./whatsapp), with its signature check, payload parser, Graph sender and Embedded Signup helpers. Framework-neutral webhook routes (./server), dep-free job blueprints and the package-owned Prisma partial + migrations.",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./whatsapp": {
13
+ "types": "./dist/whatsapp/index.d.ts",
14
+ "default": "./dist/whatsapp/index.js"
15
+ },
16
+ "./server": {
17
+ "types": "./dist/server/index.d.ts",
18
+ "default": "./dist/server/index.js"
19
+ },
20
+ "./manifest": {
21
+ "types": "./dist/manifest/index.d.ts",
22
+ "default": "./dist/manifest/index.js"
23
+ },
24
+ "./manifest/server": {
25
+ "types": "./dist/manifest/server.d.ts",
26
+ "default": "./dist/manifest/server.js"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "scripts": {
31
+ "build": "rm -rf dist && tsup",
32
+ "clean": "rm -rf node_modules coverage dist",
33
+ "test": "node ../../scripts/vitest-with-teardown.mjs run",
34
+ "test:watch": "vitest watch",
35
+ "lint": "eslint src --max-warnings 0",
36
+ "check-types": "tsc --noEmit",
37
+ "typecheck": "tsc --noEmit"
38
+ },
39
+ "peerDependencies": {
40
+ "@12-apps/wiring": ">=1.3.0"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "@12-apps/wiring": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "devDependencies": {
48
+ "@12-apps/eslint-config": "^1.22.0",
49
+ "@12-apps/typescript-config": "^1.21.0",
50
+ "@12-apps/wiring": "^1.17.0",
51
+ "@electric-sql/pglite": "^0.2.17",
52
+ "@types/node": "^22.10.6",
53
+ "eslint": "^9.39.1",
54
+ "eslint-plugin-test-flakiness": "^1.4.0",
55
+ "tsup": "^8.0.0",
56
+ "typescript": "^5.9.2",
57
+ "vitest": "^3.2.4"
58
+ },
59
+ "engines": {
60
+ "node": ">=22.0.0"
61
+ },
62
+ "license": "MIT",
63
+ "publishConfig": {
64
+ "registry": "https://registry.npmjs.org",
65
+ "access": "public"
66
+ },
67
+ "repository": {
68
+ "type": "git",
69
+ "url": "git+https://github.com/12-apps/shared-packages.git",
70
+ "directory": "packages/messaging"
71
+ },
72
+ "files": [
73
+ "src",
74
+ "dist",
75
+ "prisma",
76
+ "*.js",
77
+ "*.mjs",
78
+ "*.md",
79
+ "!eslint.config.js",
80
+ "!tsup.config.ts",
81
+ "!**/__tests__/**",
82
+ "!**/tests/**",
83
+ "!**/*.test.*",
84
+ "!**/*.spec.*"
85
+ ],
86
+ "wiring": {
87
+ "db": {
88
+ "partial": "prisma/messaging.prisma",
89
+ "migrations": "prisma/migrations"
90
+ }
91
+ }
92
+ }