@im-more/dsh-whatsapp 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/cordis.patch.yml +12 -0
- package/lib/index.js +1694 -0
- package/lib/index.js.map +1 -0
- package/lib/types/bot.d.ts +66 -0
- package/lib/types/bot.d.ts.map +1 -0
- package/lib/types/bot.js +164 -0
- package/lib/types/bot.js.map +1 -0
- package/lib/types/config.d.ts +40 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +63 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/decode.d.ts +64 -0
- package/lib/types/decode.d.ts.map +1 -0
- package/lib/types/decode.js +244 -0
- package/lib/types/decode.js.map +1 -0
- package/lib/types/errors.d.ts +53 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +149 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/identity.d.ts +48 -0
- package/lib/types/identity.d.ts.map +1 -0
- package/lib/types/identity.js +52 -0
- package/lib/types/identity.js.map +1 -0
- package/lib/types/index.d.ts +16 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +15 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/interactive.d.ts +45 -0
- package/lib/types/interactive.d.ts.map +1 -0
- package/lib/types/interactive.js +111 -0
- package/lib/types/interactive.js.map +1 -0
- package/lib/types/internal.d.ts +28 -0
- package/lib/types/internal.d.ts.map +1 -0
- package/lib/types/internal.js +35 -0
- package/lib/types/internal.js.map +1 -0
- package/lib/types/media.d.ts +17 -0
- package/lib/types/media.d.ts.map +1 -0
- package/lib/types/media.js +49 -0
- package/lib/types/media.js.map +1 -0
- package/lib/types/modes/shared.d.ts +112 -0
- package/lib/types/modes/shared.d.ts.map +1 -0
- package/lib/types/modes/shared.js +285 -0
- package/lib/types/modes/shared.js.map +1 -0
- package/lib/types/modes/text.d.ts +19 -0
- package/lib/types/modes/text.d.ts.map +1 -0
- package/lib/types/modes/text.js +126 -0
- package/lib/types/modes/text.js.map +1 -0
- package/lib/types/request.d.ts +61 -0
- package/lib/types/request.d.ts.map +1 -0
- package/lib/types/request.js +193 -0
- package/lib/types/request.js.map +1 -0
- package/lib/types/send.d.ts +47 -0
- package/lib/types/send.d.ts.map +1 -0
- package/lib/types/send.js +74 -0
- package/lib/types/send.js.map +1 -0
- package/lib/types/signature.d.ts +33 -0
- package/lib/types/signature.d.ts.map +1 -0
- package/lib/types/signature.js +46 -0
- package/lib/types/signature.js.map +1 -0
- package/lib/types/transport/webhook.d.ts +50 -0
- package/lib/types/transport/webhook.d.ts.map +1 -0
- package/lib/types/transport/webhook.js +197 -0
- package/lib/types/transport/webhook.js.map +1 -0
- package/lib/types/types.d.ts +198 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/types.js +2 -0
- package/lib/types/types.js.map +1 -0
- package/package.json +61 -3
- package/src/bot.ts +233 -0
- package/src/config.ts +98 -0
- package/src/decode.ts +335 -0
- package/src/errors.ts +189 -0
- package/src/identity.ts +76 -0
- package/src/index.ts +100 -0
- package/src/interactive.ts +135 -0
- package/src/internal.ts +49 -0
- package/src/media.ts +59 -0
- package/src/modes/shared.ts +354 -0
- package/src/modes/text.ts +174 -0
- package/src/request.ts +238 -0
- package/src/send.ts +120 -0
- package/src/signature.ts +54 -0
- package/src/transport/webhook.ts +267 -0
- package/src/types.ts +244 -0
- package/README.md +0 -3
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["messageOf","messageOf","messageOf","messageOf"],"sources":["types/config.js","types/errors.js","types/identity.js","types/internal.js","types/media.js","types/modes/shared.js","types/modes/text.js","types/request.js","types/send.js","types/interactive.js","types/decode.js","types/signature.js","types/transport/webhook.js","types/bot.js"],"sourcesContent":["import z from '@deepseek-ai/schemastery';\n/** Validated WhatsApp adapter configuration. */\nexport const Config = z.object({\n phoneNumberId: z.string().required(),\n systemToken: z.string().role('secret').required(),\n verifyToken: z.string().role('secret').required(),\n secret: z.string().role('secret').required(),\n apiBaseUrl: z.string().role('url').default('https://graph.facebook.com'),\n webhook: z\n .object({\n path: z.string().default('/whatsapp'),\n })\n .default({}),\n linkPreview: z.boolean().default(true),\n});\n/**\n * Normalize a route path: absolute, no trailing slash.\n *\n * @param path - a configured path.\n * @returns the pathname to register on the web server.\n */\nexport function routePath(path) {\n const withSlash = path.startsWith('/') ? path : `/${path}`;\n return withSlash.length > 1 ? withSlash.replace(/\\/+$/, '') : withSlash;\n}\n/**\n * The configuration the adapter cannot work from, as far as it can tell locally.\n *\n * WhatsApp has only the webhook transport, so a profile without a usable callback path receives nothing; the check\n * runs when the bot starts, not on the first delivery.\n *\n * @param config - the validated configuration.\n * @returns the configuration error, or undefined when the configuration is usable.\n */\nexport function configError(config) {\n if (config.phoneNumberId === '') {\n return new Error('whatsapp: phoneNumberId is required (the Graph id of the phone number, from the Meta app WhatsApp API setup)');\n }\n if (config.systemToken === '') {\n return new Error('whatsapp: systemToken is required (the system user token that authenticates every Graph call)');\n }\n if (config.verifyToken === '') {\n return new Error('whatsapp: verifyToken is required (the subscription handshake compares it with hub.verify_token)');\n }\n if (config.secret === '') {\n return new Error('whatsapp: secret is required (the App Secret; it verifies X-Hub-Signature-256 of every delivery)');\n }\n if (config.apiBaseUrl === '') {\n return new Error('whatsapp: apiBaseUrl is required (the Graph API root, https://graph.facebook.com by default)');\n }\n let origin;\n try {\n origin = new URL(config.apiBaseUrl);\n }\n catch {\n return new Error(`whatsapp: apiBaseUrl must be an absolute URL, got \"${config.apiBaseUrl}\"`);\n }\n if (origin.protocol !== 'https:') {\n return new Error(`whatsapp: apiBaseUrl must be an https URL, got \"${config.apiBaseUrl}\" (every Graph call carries a bearer token)`);\n }\n return undefined;\n}\n//# sourceMappingURL=config.js.map","/**\n * The failure shape of one Graph call and its mapping onto the core platform taxonomy.\n *\n * Meta rejects a message in one atomic request — authentication, the recipient, the 24-hour window, template\n * parameters and media ids are all checked before anything is delivered — so an answer carrying an error code means\n * nothing was published. Only a failure whose answer itself is inconclusive leaves the outcome unknown.\n */\nimport { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';\n/**\n * One failed Graph call.\n *\n * The Graph API answers a refusal with `{ error: { message, type, code, error_subcode?, fbtrace_id,\n * error_data? } }`, or with a page no proxy should produce.\n */\nexport class WhatsappApiError extends Error {\n status;\n code;\n subcode;\n platformMessage;\n type;\n details;\n bodyText;\n nonJson;\n constructor(message, init = {}) {\n super(message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = 'WhatsappApiError';\n this.status = init.status;\n this.code = init.code;\n this.subcode = init.subcode;\n this.platformMessage = init.platformMessage;\n this.type = init.type;\n this.details = init.details;\n this.bodyText = init.bodyText;\n this.nonJson = init.nonJson ?? false;\n }\n}\n/**\n * The Graph codes that override the status-based default (§7.2).\n *\n * The `132xxx` entries are template errors: this adapter sends no template, and the table stays for a caller of\n * `bot.internal.sendMessage` and for a future template mode.\n */\nconst CODE_RULES = new Map([\n // The bearer token is invalid, expired or revoked.\n [190, { kind: 'permission', published: 'no' }],\n // Invalid or missing request parameters.\n [100, { kind: 'invalid', published: 'no' }],\n [131008, { kind: 'invalid', published: 'no' }],\n [131009, { kind: 'invalid', published: 'no' }],\n [131021, { kind: 'invalid', published: 'no' }],\n // The recipient cannot receive a message.\n [131026, { kind: 'not-found', published: 'no' }],\n // The 24-hour customer service window is closed; the message is refused for re-engagement.\n [131047, { kind: 'invalid', published: 'no' }],\n // Throughput and pair rate limits.\n [4, { kind: 'rate-limit', published: 'no' }],\n [80007, { kind: 'rate-limit', published: 'no' }],\n [130429, { kind: 'rate-limit', published: 'no' }],\n [131048, { kind: 'rate-limit', published: 'no' }],\n [131056, { kind: 'rate-limit', published: 'no' }],\n // The business account is restricted, locked or unqualified.\n [368, { kind: 'permission', published: 'no' }],\n [131031, { kind: 'permission', published: 'no' }],\n [131042, { kind: 'permission', published: 'no' }],\n [133004, { kind: 'permission', published: 'no' }],\n [133005, { kind: 'permission', published: 'no' }],\n [133006, { kind: 'permission', published: 'no' }],\n [133008, { kind: 'permission', published: 'no' }],\n [133010, { kind: 'permission', published: 'no' }],\n // The platform itself reports an unknown failure: it may have published the message.\n [131000, { kind: 'retryable', published: 'unknown' }],\n [131016, { kind: 'retryable', published: 'unknown' }],\n // Template parameters, template state.\n [132000, { kind: 'invalid', published: 'no' }],\n [132001, { kind: 'invalid', published: 'no' }],\n [132005, { kind: 'invalid', published: 'no' }],\n [132007, { kind: 'invalid', published: 'no' }],\n [132012, { kind: 'invalid', published: 'no' }],\n [132015, { kind: 'invalid', published: 'no' }],\n [132016, { kind: 'invalid', published: 'no' }],\n]);\n/** The message of a re-engagement refusal names the window and the only way out of it. */\nconst CLOSED_WINDOW = 'whatsapp: the 24-hour customer service window is closed (131047): a free-form message ' +\n 'cannot be sent until the recipient writes again, and only a template message could reach them before that';\n/** Whether a caught value is an abort error, including the `DOMException` a signal produces. */\nfunction isAbortError(error) {\n return ((error instanceof Error || error instanceof DOMException) &&\n error.name === 'AbortError');\n}\n/**\n * Map any failure onto the core platform taxonomy.\n *\n * @param error - the caught failure.\n * @returns the classified platform error.\n */\nexport function classifyWhatsappError(error) {\n if (error instanceof PlatformError)\n return error;\n if (error instanceof WhatsappApiError) {\n // The Graph `code` is the platform's own identity of the failure; the HTTP status is only the transport's view.\n const code = error.code ?? error.status;\n const init = {\n ...(code === undefined ? {} : { code }),\n cause: error,\n };\n // No answer at all, or an answer that is not the Graph JSON envelope (a proxy page, a cut-off reply): the status\n // alone cannot say whether the request was rejected or half-processed.\n if (error.status === undefined || error.nonJson) {\n return new PlatformError('retryable', error.message, {\n ...init,\n published: 'unknown',\n });\n }\n if (error.code === 131047) {\n return new PlatformError('invalid', CLOSED_WINDOW, {\n code: error.code,\n published: 'no',\n cause: error,\n });\n }\n const rule = error.code === undefined ? undefined : CODE_RULES.get(error.code);\n if (rule !== undefined) {\n return new PlatformError(rule.kind, error.message, {\n ...init,\n published: rule.published,\n });\n }\n if (error.status >= 500) {\n return new PlatformError('retryable', error.message, {\n ...init,\n published: 'unknown',\n });\n }\n // Every other answered 4xx: the request was refused before delivery, so nothing was published.\n return new PlatformError('invalid', error.message, {\n ...init,\n published: 'no',\n });\n }\n if (isAbortError(error)) {\n return new PlatformError('fatal', error.message, {\n published: 'unknown',\n cause: error,\n });\n }\n const message = error instanceof Error ? error.message : String(error);\n return new PlatformError('retryable', `whatsapp: request failed: ${message}`, { published: 'unknown', cause: error });\n}\n//# sourceMappingURL=errors.js.map","/**\n * The phone number a bot speaks for.\n *\n * The Cloud API names a number by its Graph id in every path (`POST /{phoneNumberId}/messages`), while the webhook\n * addresses it by `metadata.phone_number_id`. The adapter configures the id (one row per number) and proves on connect\n * that the configured token reaches that number: a token/row mismatch would otherwise surface only on the first send.\n */\n/** Failure to confirm the configured phone number. */\nexport class WhatsappIdentityError extends Error {\n constructor(message) {\n super(message);\n this.name = 'WhatsappIdentityError';\n }\n}\n/**\n * Read the configured phone number.\n *\n * @param request - the Graph client of the configured number.\n * @param phoneNumberId - the configured Graph id.\n * @returns the number's display name and itself.\n * @throws WhatsappApiError when the token cannot read that number.\n */\nexport async function fetchPhoneNumber(request, phoneNumberId) {\n return await request.get(`/${encodeURIComponent(phoneNumberId)}`, { fields: 'display_phone_number,verified_name' });\n}\n/**\n * Verify a `GET /{phoneNumberId}` answer against the configured id.\n *\n * @param phoneNumberId - the configured Graph id.\n * @param info - the read-back.\n * @returns the Graph id, which is `phoneNumberId`.\n * @throws WhatsappIdentityError when the answer names another number.\n */\nexport function verifyIdentity(phoneNumberId, info) {\n if (info.id !== phoneNumberId) {\n throw new WhatsappIdentityError(`whatsapp: phoneNumberId is ${phoneNumberId} but GET /${phoneNumberId} returned ${info.id}`);\n }\n return info.id;\n}\n/**\n * The bot's own platform identity.\n *\n * The display phone number is the only human-readable name the Cloud API gives a business number; `wa_id` is not in\n * any payload, and deriving it from the display form would be a guess.\n *\n * @param info - the verified read-back.\n * @returns the user of `bot.user`.\n */\nexport function userOf(info) {\n return { id: info.id, name: info.display_phone_number, isBot: true };\n}\n//# sourceMappingURL=identity.js.map","export class Internal {\n http;\n constructor(http) {\n this.http = http;\n }\n async getPhoneNumbers(id) {\n // https://developers.facebook.com/docs/whatsapp/business-management-api/manage-phone-numbers#all-phone-numbers\n const { data } = await this.http.get(`/${id}/phone_numbers`);\n return data;\n }\n async messageReaction(selfId, channelId, messageId, emoji) {\n // https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-messages#reaction-messages\n await this.http.post(`/${selfId}/messages`, {\n messaging_product: 'whatsapp',\n to: channelId,\n recipient_type: 'individual',\n type: 'reaction',\n reaction: {\n message_id: messageId,\n emoji,\n },\n });\n }\n async sendMessage(selfId, data) {\n const response = await this.http.post(`/${selfId}/messages`, data);\n return response;\n }\n getMedia(mediaId) {\n return this.http.get('/' + mediaId);\n }\n uploadMedia(selfId, form) {\n return this.http.post(`/${selfId}/media`, form);\n }\n}\n//# sourceMappingURL=internal.js.map","/**\n * Inbound media: the `satori:` route behind an image, audio, video or document element.\n *\n * The webhook names a media id, never a URL. Reading the bytes takes two requests: `GET /{mediaId}` resolves a\n * short-lived address, and fetching that address — still with the bearer token — returns the bytes. The address is\n * therefore resolved per request instead of being baked into the stored message.\n */\n/** Message of any caught value, for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/**\n * Serve the bytes of one received media object.\n *\n * @param bot - the receiving adapter.\n * @param mediaId - the media id the webhook named.\n * @returns the download answer, status and content headers included, or `502` when either step failed.\n */\nexport async function serveMedia(bot, mediaId) {\n let address;\n try {\n const resolved = await bot.internal.getMedia(mediaId);\n address = resolved.url;\n }\n catch (error) {\n bot.ctx.logger.warn('whatsapp: media %s could not be resolved: %s', mediaId, messageOf(error));\n return new Response(null, { status: 502 });\n }\n let downloaded;\n try {\n downloaded = await bot.request.download(address);\n }\n catch (error) {\n bot.ctx.logger.warn('whatsapp: media %s could not be downloaded: %s', mediaId, messageOf(error));\n return new Response(null, { status: 502 });\n }\n const headers = new Headers();\n const mime = downloaded.headers.get('content-type');\n if (mime !== null)\n headers.set('content-type', mime);\n const length = downloaded.headers.get('content-length');\n if (length !== null)\n headers.set('content-length', length);\n return new Response(downloaded.status === 200 ? downloaded.body : null, {\n status: downloaded.status,\n headers,\n });\n}\n//# sourceMappingURL=media.js.map","/**\n * Shared types and the draft machinery of the single `text` mode.\n *\n * One draft is exactly one platform message: WhatsApp has no request that carries several messages, so every draft is\n * a `POST /{phoneNumberId}/messages` of its own. Text accumulates into a body that the platform's inline marks can\n * format, each media element becomes a message of its own, and reply buttons become one interactive message.\n */\nimport { isPhrasingContainer } from '@deepseek-ai/satori-element';\n/** The platform's documented bounds. */\nexport const WHATSAPP_LIMITS = {\n /** One text message body: 4,096 characters. */\n text: 4_096,\n /** Reply buttons one interactive message accepts. */\n buttons: 3,\n /** One reply button title: 20 characters. */\n buttonTitle: 20,\n};\n/**\n * The media types the Cloud API accepts, verbatim from the platform's documented list.\n *\n * The upload endpoint answers `100`/`131009` for anything else, so the adapter refuses an unsupported source before it\n * sends a request. `audio/opus` is the one entry the upstream adapter added to the platform list.\n */\nexport const SUPPORTED_MEDIA = [\n 'audio/aac',\n 'audio/mp4',\n 'audio/mpeg',\n 'audio/amr',\n 'audio/ogg',\n 'audio/opus',\n 'application/vnd.ms-powerpoint',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/pdf',\n 'text/plain',\n 'application/vnd.ms-excel',\n 'image/jpeg',\n 'image/png',\n 'image/webp',\n 'video/mp4',\n 'video/3gpp',\n];\n/** Report inline media that moves out of its text run into a message of its own. */\nexport function reportMovedMedia(el, ctx) {\n const parent = ctx.ancestors[ctx.ancestors.length - 1];\n if (parent !== undefined && isPhrasingContainer(parent.type)) {\n ctx.report.moved.push({\n tag: el.type,\n reason: 'whatsapp-media-split',\n path: ctx.stableId(el),\n });\n }\n}\n/**\n * The latest paragraph, line or space boundary at or before `limit`.\n *\n * The whitespace that ends the boundary stays in the chunk, so concatenating the chunks reproduces the input.\n *\n * @param text - the text to cut.\n * @param limit - the maximum chunk length in UTF-16 code units.\n * @returns the cut index including the boundary whitespace, or -1 for none.\n */\nfunction boundaryCut(text, limit) {\n const window = text.slice(0, limit);\n const paragraph = window.lastIndexOf('\\n\\n');\n if (paragraph >= 0)\n return paragraph + 2;\n const line = window.lastIndexOf('\\n');\n if (line >= 0)\n return line + 1;\n const space = window.lastIndexOf(' ');\n if (space >= 0)\n return space + 1;\n return -1;\n}\n/** Move a cut left by one unit when it would fall inside a surrogate pair. */\nfunction avoidSplitPair(text, cut) {\n if (cut <= 0 || cut >= text.length)\n return cut;\n const before = text.charCodeAt(cut - 1);\n const after = text.charCodeAt(cut);\n const high = before >= 0xd800 && before <= 0xdbff;\n const low = after >= 0xdc00 && after <= 0xdfff;\n return high && low ? cut - 1 : cut;\n}\n/**\n * Cut text into chunks a text message accepts.\n *\n * Point cuts prefer a paragraph break, then a line break, then a space, then a code-unit boundary that does not split a\n * surrogate pair. The chunks concatenate back to the input.\n *\n * @param text - the text to cut.\n * @param limit - the maximum chunk length in UTF-16 code units.\n * @returns one or more chunks.\n */\nexport function splitText(text, limit) {\n if (text.length <= limit)\n return [text];\n const chunks = [];\n let rest = text;\n while (rest.length > limit) {\n let cut = boundaryCut(rest, limit);\n if (cut <= 0)\n cut = Math.max(1, limit);\n cut = Math.max(1, avoidSplitPair(rest, cut));\n chunks.push(rest.slice(0, cut));\n rest = rest.slice(cut);\n }\n if (rest !== '')\n chunks.push(rest);\n return chunks;\n}\n/** The carrier text of a message that exists only to show replies, and of every later button group. */\nconst BUTTON_CARRIER = ' ';\n/** One media draft of a node. */\nfunction mediaDraftOf(node) {\n const type = node.kind === 'file' ? 'document' : node.kind;\n return {\n kind: 'media',\n type,\n ref: node.ref,\n ...(node.name === undefined ? {} : { name: node.name }),\n };\n}\n/**\n * Fold a node stream into platform messages.\n *\n * Text accumulates into one body; a media element closes the text body that precedes it and becomes a message of its\n * own; buttons become one interactive message per three, sent before the text that follows the last media element, as\n * the platform shows the body on the first group and nothing on the rest.\n *\n * @param nodes - rendered nodes, in document order.\n * @param ctx - the render context, for the split count.\n * @returns one draft per platform message, in send order; never empty.\n */\nexport function assembleDraft(nodes, ctx) {\n const drafts = [];\n const buttons = [];\n let buffer = '';\n let split = 0;\n const flushText = () => {\n const text = buffer;\n buffer = '';\n if (text === '')\n return;\n const chunks = splitText(text, WHATSAPP_LIMITS.text);\n split += chunks.length - 1;\n for (const chunk of chunks)\n drafts.push({ kind: 'text', body: chunk });\n };\n const flushButtons = () => {\n // The body rides the first group so the reader sees the text with the buttons it belongs to.\n const body = buffer === '' ? BUTTON_CARRIER : buffer;\n buffer = '';\n for (let index = 0; index < buttons.length; index += WHATSAPP_LIMITS.buttons) {\n drafts.push({\n kind: 'buttons',\n body: index === 0 ? body : BUTTON_CARRIER,\n buttons: buttons.slice(index, index + WHATSAPP_LIMITS.buttons),\n });\n }\n buttons.length = 0;\n };\n for (const node of nodes) {\n switch (node.type) {\n case 'text':\n buffer += node.text;\n break;\n case 'media':\n flushText();\n drafts.push(mediaDraftOf(node));\n break;\n case 'button':\n buttons.push({ id: node.id, title: node.title });\n break;\n }\n }\n if (buttons.length > 0)\n flushButtons();\n flushText();\n ctx.report.split += split;\n // Content the pipeline accepts always yields something; a mode may never answer with no platform message.\n if (drafts.length === 0)\n drafts.push({ kind: 'text', body: BUTTON_CARRIER });\n return drafts;\n}\n/** One resolved resource key of a prepared draft. */\nfunction resolvedKey(prepared, ref) {\n const resolved = prepared.resolved.get(ref);\n if (resolved === undefined) {\n throw new Error('whatsapp: media was not prepared before serialize');\n }\n return resolved.key;\n}\n/** The platform-neutral part of a request body. */\nfunction baseOf(to, ctx) {\n // Only the first message of a logical message answers the quote; the platform rejects a reply to itself.\n return {\n messaging_product: 'whatsapp',\n recipient_type: 'individual',\n to,\n ...(ctx.index !== 0 || ctx.quote === undefined\n ? {}\n : { context: { message_id: ctx.quote } }),\n };\n}\n/** One media request body, per kind, because the media detail sits under the type name. */\nfunction mediaPayload(type, id, base) {\n switch (type) {\n case 'image':\n return { ...base, type: 'image', image: { id } };\n case 'audio':\n return { ...base, type: 'audio', audio: { id } };\n case 'video':\n return { ...base, type: 'video', video: { id } };\n case 'document':\n return { ...base, type: 'document', document: { id } };\n case 'sticker':\n return { ...base, type: 'sticker', sticker: { id } };\n }\n}\n/**\n * Build the exact request body of one prepared draft.\n *\n * @param prepared - the draft with its resource keys resolved.\n * @param ctx - the send context: target, part index and quoted message.\n * @param linkPreview - whether a text body asks the client for a link preview.\n * @returns the request body.\n */\nexport function serializeDraft(prepared, ctx, linkPreview) {\n const draft = prepared.draft;\n const base = baseOf(ctx.target.chat.id, ctx);\n switch (draft.kind) {\n case 'text':\n return {\n ...base,\n type: 'text',\n text: { body: draft.body, preview_url: linkPreview },\n };\n case 'media':\n return mediaPayload(draft.type, resolvedKey(prepared, draft.ref), base);\n case 'buttons': {\n const buttons = draft.buttons.map((button) => ({\n type: 'reply',\n id: button.id,\n title: button.title,\n }));\n return {\n ...base,\n type: 'button',\n body: { text: draft.body },\n action: { buttons },\n };\n }\n }\n}\n/**\n * Hard platform limits of one draft, checked before any request.\n *\n * Text splitting and button grouping already keep the draft inside the character and count bounds; what `assemble`\n * cannot guarantee without changing the content is a button title over 20 characters, which the platform refuses.\n *\n * @param draft - the assembled draft.\n * @returns every violation the platform would refuse.\n */\nexport function checkDraft(draft) {\n if (draft.kind !== 'buttons')\n return [];\n const violations = [];\n for (const button of draft.buttons) {\n if (button.title.length <= WHATSAPP_LIMITS.buttonTitle)\n continue;\n violations.push({\n kind: 'size',\n limit: WHATSAPP_LIMITS.buttonTitle,\n actual: button.title.length,\n message: `WhatsApp reply button titles accept ${WHATSAPP_LIMITS.buttonTitle} characters, ` +\n `\"${button.title}\" has ${button.title.length}`,\n });\n }\n return violations;\n}\n//# sourceMappingURL=shared.js.map","/**\n * `text` mode: the only outbound representation the Cloud API programs against.\n *\n * The body is sent verbatim — WhatsApp has no escaping convention — but the platform documents four inline marks plus a\n * quoted-line prefix, so bold, italic, strike-through, monospace and block quotes reach the reader formatted instead of\n * disappearing. A link keeps its URL in the body because the platform has no link mark. Everything else takes the core\n * fallback and is reported as degraded; media becomes a message of its own.\n */\nimport { ElementRegistry } from '@deepseek-ai/cordis-plugin-im-core';\nimport { assembleDraft, checkDraft, reportMovedMedia, serializeDraft, WHATSAPP_LIMITS, } from \"./shared.js\";\n/** The text run of rendered children and the nodes that cannot ride inside it. */\nfunction textRun(nodes) {\n let text = '';\n const rest = [];\n for (const node of nodes) {\n if (node.type === 'text')\n text += node.text;\n else\n rest.push(node);\n }\n return { text, rest };\n}\n/** One inline mark around the rendered children, keeping any media of the subtree outside it. */\nfunction marked(children, ctx, open, close = open) {\n const run = textRun(ctx.render(children));\n if (run.text === '')\n return run.rest;\n return [{ type: 'text', text: `${open}${run.text}${close}` }, ...run.rest];\n}\n/** One media message; a media element standing in phrasing content is reported as moved, not as degraded. */\nfunction mediaNode(kind, el, ctx, src, meta) {\n reportMovedMedia(el, ctx);\n return {\n type: 'media',\n kind,\n ref: ctx.resource(kind, src, meta),\n ...(meta.name === undefined ? {} : { name: meta.name }),\n };\n}\n/** The reply button of one `button[type=action]`. */\nfunction buttonNode(el, ctx) {\n const attrs = el.attrs;\n if (attrs.type !== 'action') {\n // The registry declares the `action` variant alone, so the core fallback renders every other one.\n throw new Error(`whatsapp: <button type=\"${attrs.type}\"> has no native handler`);\n }\n return {\n type: 'button',\n id: attrs.id,\n title: ctx.text(el.children).trim(),\n };\n}\n/**\n * Build the `text` mode.\n *\n * @param config - the adapter configuration; it carries the link preview switch of every text body.\n * @returns the single mode this adapter registers.\n */\nexport function createTextMode(config) {\n const elements = new ElementRegistry()\n .register('text', (el) => ({ type: 'text', text: el.attrs.content }))\n .register('br', () => ({ type: 'text', text: '\\n' }))\n // Paragraphs hand their children through, so inline media reaches `assemble` instead of being flattened away.\n .register('p', (el, ctx) => [\n ...ctx.render(el.children),\n { type: 'text', text: '\\n\\n' },\n ])\n .register('b', (el, ctx) => marked(el.children, ctx, '*'))\n .register('i', (el, ctx) => marked(el.children, ctx, '_'))\n .register('s', (el, ctx) => marked(el.children, ctx, '~'))\n // The platform's monospace mark has one form only: triple backticks, inline and block alike.\n .register('code', (el, ctx) => marked(el.children, ctx, '```'))\n .register('pre', (el, ctx) => marked(el.children, ctx, '```\\n', '\\n```'), {\n variants: ['lang'],\n })\n .register('blockquote', (el, ctx) => {\n const run = textRun(ctx.render(el.children));\n // The last paragraph of the subtree ends on a blank line; a quote does not spell it as an empty quoted line.\n const quoted = run.text\n .replace(/\\n+$/, '')\n .split('\\n')\n .map((line) => `> ${line}`)\n .join('\\n');\n return [{ type: 'text', text: quoted }, ...run.rest];\n })\n .register('a', (el, ctx) => {\n const run = textRun(ctx.render(el.children));\n // WhatsApp auto-links a bare URL and has no link mark; appending the target keeps it visible in the body.\n const text = run.text.trim() === ''\n ? el.attrs.href\n : `${run.text} (${el.attrs.href})`;\n return [{ type: 'text', text }, ...run.rest];\n })\n .register('img', (el, ctx) => mediaNode('image', el, ctx, el.attrs.src, {}), { variants: ['inline'] })\n .register('audio', (el, ctx) => mediaNode('audio', el, ctx, el.attrs.src, {\n ...(el.attrs.name === undefined ? {} : { name: el.attrs.name }),\n ...(el.attrs.duration === undefined\n ? {}\n : { duration: el.attrs.duration }),\n }))\n .register('video', (el, ctx) => mediaNode('video', el, ctx, el.attrs.src, {\n ...(el.attrs.name === undefined ? {} : { name: el.attrs.name }),\n ...(el.attrs.duration === undefined\n ? {}\n : { duration: el.attrs.duration }),\n }))\n .register('file', (el, ctx) => mediaNode('file', el, ctx, el.attrs.src, {\n ...(el.attrs.name === undefined ? {} : { name: el.attrs.name }),\n ...(el.attrs.size === undefined ? {} : { size: el.attrs.size }),\n }))\n .register('button', (el, ctx) => buttonNode(el, ctx), {\n variants: ['action'],\n })\n .register('button-group', (el, ctx) => ctx.render(el.children));\n return {\n id: 'text',\n elements,\n limits: {\n 'limit.text.chars': WHATSAPP_LIMITS.text,\n },\n assemble: (nodes, _envelope, ctx) => assembleDraft(nodes, ctx),\n serialize: (prepared, ctx) => serializeDraft(prepared, ctx, config.linkPreview),\n check: (draft) => checkDraft(draft),\n };\n}\n//# sourceMappingURL=text.js.map","/**\n * The transport every WhatsApp Cloud API call shares: API root, bearer authentication, Graph error decoding, JSON\n * unwrapping, and the byte download of an inbound media.\n *\n * `Internal` (the migrated platform API map) and the hand-written calls (identity, media address, upload, download) go\n * through the same class, so they cannot diverge in authentication or failure handling.\n */\nimport { WhatsappApiError } from \"./errors.js\";\n/** How much of a body that carried no Graph error is kept in the error and the log; enough to recognise a gateway page. */\nconst BODY_PREFIX_BYTES = 512;\n/** Message of any caught value, for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/** Whether a failed `ctx.http` call was the caller's cancellation rather than a transport failure. */\nfunction isCancellation(cause, signal) {\n if (signal?.aborted === true)\n return true;\n if ((cause instanceof Error || cause instanceof DOMException) &&\n cause.name === 'AbortError')\n return true;\n return signal?.reason !== undefined && cause === signal.reason;\n}\n/** A cancelled request rejects with the signal's reason, so the classifier sees the cancellation itself. */\nfunction cancellation(cause, signal) {\n return signal?.aborted === true ? signal.reason : cause;\n}\n/** One JSON object, when the value is a plain object. */\nfunction asRecord(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? value\n : undefined;\n}\n/** The `error` member of a Graph answer, when the answer carries one. */\nfunction errorEnvelopeOf(body) {\n return asRecord(asRecord(body)?.error);\n}\n/**\n * One numeric member of a Graph error envelope; the platform sends a number, an older reply a numeric string.\n * @param value - the member to read.\n * @returns the number, or undefined when the member is absent or not numeric.\n */\nfunction numberOf(value) {\n if (typeof value === 'number' && Number.isFinite(value))\n return value;\n if (typeof value === 'string' &&\n value !== '' &&\n Number.isFinite(Number(value)))\n return Number(value);\n return undefined;\n}\n/**\n * The Graph API client of one configured phone number.\n *\n * Every call carries `Authorization: Bearer <systemToken>`; a refusal raises {@link WhatsappApiError} carrying the\n * HTTP status and the Graph error `code`, which {@link classifyWhatsappError} maps onto the core taxonomy.\n */\nexport class WhatsAppRequest {\n ctx;\n config;\n /** API root without its trailing slashes (`apiBaseUrl`, or a Graph version pinned into it). */\n baseUrl;\n constructor(ctx, config) {\n this.ctx = ctx;\n this.config = config;\n this.baseUrl = config.apiBaseUrl.replace(/\\/+$/, '');\n }\n /**\n * One endpoint under the API root.\n * @param method - HTTP method.\n * @param path - endpoint path, starting with `/`.\n * @param data - JSON body or multipart form; absent on a read.\n * @param signal - cancellation.\n * @returns the parsed JSON answer.\n * @throws WhatsappApiError when the call failed or did not answer with JSON.\n */\n async invoke(method, path, data, signal) {\n const url = `${this.baseUrl}${path}`;\n let response;\n try {\n response = await this.ctx.http(url, {\n method,\n headers: { authorization: `Bearer ${this.config.systemToken}` },\n ...(data === undefined ? {} : { data }),\n ...(signal === undefined ? {} : { signal }),\n });\n }\n catch (cause) {\n if (isCancellation(cause, signal))\n throw cancellation(cause, signal);\n throw new WhatsappApiError(`whatsapp: ${method} ${path} request failed: ${messageOf(cause)}`, { cause });\n }\n let text;\n try {\n text = await response.text();\n }\n catch (cause) {\n // Reading the body fails when the caller cancelled mid-answer; that is still a cancellation.\n if (isCancellation(cause, signal))\n throw cancellation(cause, signal);\n throw new WhatsappApiError(`whatsapp: ${method} ${path} answered ${response.status} but its body could not be read`, { status: response.status, cause });\n }\n let body;\n let nonJson = false;\n if (text !== '') {\n try {\n body = JSON.parse(text);\n }\n catch {\n nonJson = true;\n }\n }\n if (response.status < 200 || response.status >= 300 || nonJson) {\n const envelope = errorEnvelopeOf(body);\n const platformMessage = typeof envelope?.message === 'string' ? envelope.message : undefined;\n const errorData = asRecord(envelope?.error_data);\n throw new WhatsappApiError(`whatsapp: ${method} ${path} answered ${response.status}` +\n (platformMessage === undefined ? '' : `: ${platformMessage}`), {\n status: response.status,\n ...(numberOf(envelope?.code) === undefined\n ? {}\n : { code: numberOf(envelope?.code) }),\n ...(numberOf(envelope?.error_subcode) === undefined\n ? {}\n : { subcode: numberOf(envelope?.error_subcode) }),\n ...(platformMessage === undefined ? {} : { platformMessage }),\n ...(typeof envelope?.type === 'string'\n ? { type: envelope.type }\n : {}),\n ...(typeof errorData?.details === 'string'\n ? { details: errorData.details }\n : {}),\n ...(text === ''\n ? {}\n : { bodyText: text.slice(0, BODY_PREFIX_BYTES) }),\n nonJson,\n });\n }\n return body;\n }\n /**\n * Read one endpoint.\n * @param path - endpoint path, starting with `/`.\n * @param params - query parameters, when the endpoint takes any.\n * @param signal - cancellation.\n * @returns the parsed JSON answer.\n */\n async get(path, params, signal) {\n let search = '';\n if (params !== undefined) {\n const query = new URLSearchParams();\n for (const [key, value] of Object.entries(params))\n query.append(key, String(value));\n search = query.toString();\n }\n return await this.invoke('GET', `${path}${search === '' ? '' : `?${search}`}`, undefined, signal);\n }\n /**\n * Post one JSON body or multipart form to an endpoint.\n * @param path - endpoint path, starting with `/`.\n * @param data - JSON body or {@link FormData}.\n * @param signal - cancellation.\n * @returns the parsed JSON answer.\n */\n async post(path, data, signal) {\n return await this.invoke('POST', path, data, signal);\n }\n /**\n * Download the bytes behind a resolved media address.\n *\n * The media address is short-lived and requires the same bearer token as the API itself. The answer is returned as\n * it arrived, whatever its status: the caller maps `200` to the bytes and anything else to \"unavailable\".\n *\n * @param url - the address `GET /{mediaId}` returned.\n * @param signal - cancellation.\n * @returns the download answer.\n * @throws WhatsappApiError when the request never got an answer.\n */\n async download(url, signal) {\n try {\n return await this.ctx.http(url, {\n headers: { authorization: `Bearer ${this.config.systemToken}` },\n ...(signal === undefined ? {} : { signal }),\n });\n }\n catch (cause) {\n if (isCancellation(cause, signal))\n throw cancellation(cause, signal);\n throw new WhatsappApiError(`whatsapp: media download failed: ${messageOf(cause)}`, { cause });\n }\n }\n}\n//# sourceMappingURL=request.js.map","/**\n * Outbound: one request per draft, and the two reaction hooks.\n *\n * The Cloud API answers `POST /{phoneNumberId}/messages` with `{ messages: [{ id }], contacts }`. The id is the\n * `wamid` of the published message; an answer without one means the request was accepted but its outcome cannot be\n * described, so it is reported as a platform error with an unknown outcome instead of a success.\n */\nimport { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';\n/** The media id a media request carries, when the payload is a media message. */\nfunction mediaIdOf(payload) {\n switch (payload.type) {\n case 'image':\n return payload.image?.id;\n case 'audio':\n return payload.audio?.id;\n case 'video':\n return payload.video?.id;\n case 'document':\n return payload.document?.id;\n case 'sticker':\n return payload.sticker?.id;\n default:\n return undefined;\n }\n}\n/**\n * Send one serialized payload and report the part the platform created.\n *\n * @param deps - the adapter's API surface.\n * @param payload - one request body.\n * @param _target - the chat the payload goes to; the recipient rides `payload.to`.\n * @param _ctx - the core send context; this adapter keeps no per-part state.\n * @returns the published part.\n * @throws PlatformError `invalid` when the answer carries no message id, with an unknown outcome.\n */\nexport async function sendPayload(deps, payload, _target, _ctx) {\n const answer = await deps.internal.sendMessage(deps.selfId, payload);\n const id = answer?.messages?.[0]?.id;\n if (id === undefined || id === '') {\n // The request reached the platform and was accepted, but no message id came back: the outcome is not \"unpublished\".\n throw new PlatformError('invalid', 'whatsapp: sendMessage answered without a message id', { published: 'unknown' });\n }\n const mediaId = mediaIdOf(payload);\n return {\n id,\n kind: 'message',\n time: Date.now(),\n raw: { waId: payload.to, ...(mediaId === undefined ? {} : { mediaId }) },\n };\n}\n/**\n * Add the reaction of the bot to one published message.\n *\n * @param deps - the adapter's API surface.\n * @param message - the message to react to.\n * @param emoji - the reaction, passed through as the payload spells it.\n */\nexport async function createReaction(deps, message, emoji) {\n await deps.internal.messageReaction(deps.selfId, message.chat.id, message.id, emoji);\n}\n/**\n * Remove the reaction of the bot from one published message.\n *\n * The platform represents \"no reaction\" as an empty emoji on the same endpoint, so the emoji to remove is not part of\n * the request: a number holds one reaction per message, and clearing it clears whichever one it is.\n *\n * @param deps - the adapter's API surface.\n * @param message - the message to clear the reaction of.\n * @param _emoji - unused; the platform removes the single reaction a number may hold.\n */\nexport async function deleteReaction(deps, message, _emoji) {\n await deps.internal.messageReaction(deps.selfId, message.chat.id, message.id, '');\n}\n//# sourceMappingURL=send.js.map","/**\n * Inbound interactions and reactions.\n *\n * A WhatsApp reply button, list pick or template quick reply is not a text message: it answers a message this bot sent\n * (through `context.message_id`), and the host routes it to the callback registered under the id the button carried.\n * A reaction is the platform's only other inbound signal; removing one is an empty emoji.\n */\n/**\n * Decode a reaction into `reaction-added` or `reaction-removed`.\n *\n * The reaction names the message it applies to, the reactor and the emoji; the chat is the reactor's own conversation,\n * which is the only chat a reaction payload can come from.\n *\n * @param bot - the receiving adapter.\n * @param message - the reaction message.\n * @param context - the chat, sender and referrer of the payload.\n * @returns the session to publish.\n */\nexport function decodeReaction(bot, message, context) {\n return bot.session({\n type: message.reaction.emoji === '' ? 'reaction-removed' : 'reaction-added',\n id: message.id,\n timestamp: context.timestamp,\n reaction: {\n message: { id: message.reaction.message_id, chat: context.chat },\n emoji: message.reaction.emoji,\n user: context.user,\n },\n raw: message,\n });\n}\n/** The message an interaction answers: the one it quotes, or its own when the payload names no context. */\nfunction answeredMessageId(message) {\n return message.context?.id ?? message.id;\n}\n/**\n * Decode a reply button or a list pick.\n *\n * @param bot - the receiving adapter.\n * @param message - the interactive message.\n * @param context - the chat, sender and referrer of the payload.\n * @returns the `interaction/button` or `interaction/select` session.\n */\nexport function decodeInteractive(bot, message, context) {\n const chat = context.chat;\n const answer = { id: answeredMessageId(message), chat };\n switch (message.interactive.type) {\n case 'button_reply':\n return bot.session({\n type: 'interaction/button',\n id: message.id,\n timestamp: context.timestamp,\n button: {\n bot,\n id: message.interactive.button_reply.id,\n user: context.user,\n chat,\n message: answer,\n referrer: context.referrer,\n time: context.timestamp,\n },\n raw: message,\n });\n case 'list_reply':\n return bot.session({\n type: 'interaction/select',\n id: message.id,\n timestamp: context.timestamp,\n select: {\n bot,\n id: message.interactive.list_reply.id,\n values: [message.interactive.list_reply.title],\n user: context.user,\n chat,\n message: answer,\n referrer: context.referrer,\n time: context.timestamp,\n },\n raw: message,\n });\n }\n}\n/**\n * Decode a template quick reply.\n *\n * A template's quick reply carries an optional `payload`; a template written without one leaves the button text as the\n * only identity the reply has.\n *\n * @param bot - the receiving adapter.\n * @param message - the `button` message.\n * @param context - the chat, sender and referrer of the payload.\n * @returns the `interaction/button` session.\n */\nexport function decodeTemplateButton(bot, message, context) {\n return bot.session({\n type: 'interaction/button',\n id: message.id,\n timestamp: context.timestamp,\n button: {\n bot,\n id: message.button.payload ?? message.button.text,\n user: context.user,\n chat: context.chat,\n message: { id: message.context?.id ?? message.id, chat: context.chat },\n referrer: context.referrer,\n time: context.timestamp,\n },\n raw: message,\n });\n}\n//# sourceMappingURL=interactive.js.map","/**\n * Inbound decoding: one change of a webhook delivery becomes zero or more intake `Session`s.\n *\n * The Cloud API pushes everything at once — several entries, each with several changes, each with several messages —\n * and there is no API that reads a message back, so this payload is the only copy of the content. Every message is\n * decoded; a chat is always the sender's own `wa_id`, because this adapter supports no group.\n */\nimport { h, normalize } from '@deepseek-ai/satori-element';\nimport { decodeInteractive, decodeReaction, decodeTemplateButton, } from \"./interactive.js\";\n/** Message of any caught value, for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/** The direct chat of one sender; a Cloud API conversation has exactly one peer. */\nexport function chatRefOf(message) {\n return { id: message.from, type: 'direct' };\n}\n/**\n * The sender of one message.\n *\n * The payload names the sender's display name in `contacts`, keyed by `wa_id` — a batch can carry several senders, so\n * the entry is matched instead of taken from the first position.\n * @param message - the message being decoded.\n * @param contacts - the `contacts` array of the same change.\n * @returns the sender reference, named when the payload names it.\n */\nexport function senderOf(message, contacts) {\n const name = contacts?.find((contact) => contact.wa_id === message.from)\n ?.profile.name;\n return {\n id: message.from,\n ...(name === undefined ? {} : { name }),\n isBot: false,\n };\n}\n/** The platform timestamp of a message: Meta sends seconds as a string. */\nexport function timeOf(message) {\n const seconds = Number.parseInt(message.timestamp, 10);\n return Number.isFinite(seconds) ? seconds * 1_000 : Date.now();\n}\n/** The adapter context an interaction or reaction session is built from. */\nexport function contextOf(bot, message, contacts) {\n return {\n chat: chatRefOf(message),\n user: senderOf(message, contacts),\n referrer: {\n waId: message.from,\n messageId: message.id,\n phoneNumberId: bot.config.phoneNumberId,\n timestamp: timeOf(message),\n },\n timestamp: timeOf(message),\n };\n}\n/** The `satori:` address of one received media object. */\nfunction mediaSource(bot, media) {\n return bot.getInternalUrl(`/assets/${encodeURIComponent(media.id)}`);\n}\n/** The caption that precedes a media element, when the sender typed one. */\nfunction captionOf(media) {\n return media.caption === undefined || media.caption === ''\n ? []\n : [media.caption];\n}\n/** The elements of one media message: its caption, then the media itself. */\nfunction mediaNodes(bot, message) {\n const media = message[message.type];\n if (media === undefined)\n return [];\n const src = mediaSource(bot, media);\n const name = media.filename === undefined ? {} : { name: media.filename };\n switch (message.type) {\n case 'image':\n return [...captionOf(media), h('img', { src })];\n case 'audio':\n // A voice note is an audio message recorded in the app; the vocabulary has no separate element for it.\n return [...captionOf(media), h('audio', { src, ...name })];\n case 'video':\n return [...captionOf(media), h('video', { src, ...name })];\n case 'document':\n return [...captionOf(media), h('file', { src, ...name })];\n }\n}\n/**\n * The elements of one message of a type that carries content.\n *\n * @param bot - the receiving adapter.\n * @param message - the decoded message.\n * @returns its elements, possibly empty for a shape this snapshot does not carry.\n */\nfunction contentNodes(bot, message) {\n switch (message.type) {\n case 'text':\n return message.text.body === '' ? [] : [message.text.body];\n case 'image':\n case 'audio':\n case 'video':\n case 'document':\n return mediaNodes(bot, message);\n case 'sticker':\n return message.sticker === undefined\n ? []\n : [h('img', { src: mediaSource(bot, message.sticker), alt: '[贴纸]' })];\n case 'location':\n // The vocabulary has no location element; the coordinates are what a reader needs from one.\n return [`📍 ${message.location.latitude}, ${message.location.longitude}`];\n case 'contacts': {\n const names = message.contacts.map((contact) => contact.name.formatted_name);\n const summary = names.length === 0 ? '联系人' : `联系人:${names.join('、')}`;\n return [\n summary,\n h('raw', {\n platform: 'whatsapp',\n type: 'contacts',\n data: message.contacts,\n }),\n ];\n }\n case 'system':\n return message.system.body === '' ? [] : [message.system.body];\n default:\n return [];\n }\n}\n/**\n * The content tree of one message, never empty.\n * @param bot - the receiving adapter.\n * @param message - the decoded message.\n * @returns the normalized `<message>` root.\n */\nfunction contentOf(bot, message) {\n const nodes = contentNodes(bot, message);\n if (nodes.length > 0)\n return normalize(h('message', nodes));\n // A type this snapshot does not model still reaches the model as its payload rather than disappearing.\n return normalize(h('message', h('raw', { platform: 'whatsapp', type: message.type, data: message })));\n}\n/** The quote an inbound message answers, when the payload names one. */\nfunction quoteOf(message) {\n if (message.context === undefined)\n return undefined;\n return { id: message.context.id, sender: { id: message.context.from } };\n}\n/**\n * Decode one ordinary message into a `message` session.\n *\n * @param bot - the receiving adapter.\n * @param message - the decoded message.\n * @param contacts - the `contacts` array of the same change.\n * @returns the session to publish.\n */\nfunction messageSession(bot, message, contacts) {\n const context = contextOf(bot, message, contacts);\n const quote = quoteOf(message);\n const inbound = {\n id: message.id,\n chat: context.chat,\n sender: context.user,\n content: contentOf(bot, message),\n ...(quote === undefined ? {} : { quote }),\n // A 1:1 WhatsApp conversation has no mention syntax and the platform names no mentioned user.\n mentions: { self: false, all: false, users: [] },\n time: context.timestamp,\n referrer: context.referrer,\n raw: message,\n };\n return bot.session({\n type: 'message',\n id: message.id,\n timestamp: context.timestamp,\n message: inbound,\n raw: message,\n });\n}\n/** Log one delivery receipt; the platform's own view of an outbound message has no DSH event. */\nfunction logStatus(bot, status) {\n if (status.status !== 'failed') {\n bot.ctx.logger.debug('whatsapp: message %s is %s', status.id, status.status);\n return;\n }\n // A failed delivery is where a closed 24-hour window, a rejected template and a refused recipient first appear.\n const errors = status.errors ?? [];\n bot.ctx.logger.warn('whatsapp: delivery of %s to %s failed: %s', status.id, status.recipient_id, errors.length === 0\n ? 'no error detail'\n : errors\n .map((error) => [String(error.code), error.title, error.error_data?.details]\n .filter((part) => part !== undefined && part !== '')\n .join(' '))\n .join('; '));\n}\n/**\n * Decode every message of one change.\n *\n * A non-`messages` change family is dropped with a debug line: the IM host has no consumer for account, template or\n * quality updates. Delivery receipts never reach the message store.\n *\n * @param bot - the receiving adapter.\n * @param change - one change of one entry.\n * @returns the sessions to publish, in payload order.\n */\nexport function decodeChange(bot, change) {\n if (change.field !== 'messages') {\n bot.ctx.logger.debug('whatsapp: ignoring a %s change', change.field);\n return [];\n }\n for (const status of change.value.statuses ?? [])\n logStatus(bot, status);\n for (const error of change.value.errors ?? []) {\n bot.ctx.logger.warn('whatsapp: the webhook reported an error: %s', messageOf(error));\n }\n const sessions = [];\n for (const message of change.value.messages ?? []) {\n const session = decodeMessage(bot, message, change.value.contacts);\n if (session !== undefined)\n sessions.push(session);\n }\n return sessions;\n}\n/**\n * Decode one message of the payload.\n *\n * @param bot - the receiving adapter.\n * @param message - one `messages` entry.\n * @param contacts - the `contacts` array of the same change.\n * @returns the session to publish, or undefined for a message this adapter drops.\n */\nexport function decodeMessage(bot, message, contacts) {\n if (message.group_id !== undefined) {\n // A group message names the member who wrote it, not the conversation; treating it as a direct chat would make\n // the bot answer that member privately. v1 supports no group, so the message is dropped without a trace.\n return undefined;\n }\n switch (message.type) {\n case 'reaction':\n return decodeReaction(bot, message, contextOf(bot, message, contacts));\n case 'interactive':\n return decodeInteractive(bot, message, contextOf(bot, message, contacts));\n case 'button':\n return decodeTemplateButton(bot, message, contextOf(bot, message, contacts));\n default:\n return messageSession(bot, message, contacts);\n }\n}\n//# sourceMappingURL=decode.js.map","import { createHmac, timingSafeEqual } from 'node:crypto';\n/** Header Meta signs a delivery with. */\nexport const SIGNATURE_HEADER = 'x-hub-signature-256';\n/**\n * The `X-Hub-Signature-256` value of one delivery.\n *\n * Meta signs the request body exactly as it arrived, keyed by the App Secret.\n *\n * @param secret - the App Secret.\n * @param body - the raw request body, before any decoding.\n * @returns `sha256=` followed by the hex HMAC-SHA256 of the body.\n */\nexport function signatureOf(secret, body) {\n return `sha256=${createHmac('sha256', secret).update(body).digest('hex')}`;\n}\n/**\n * Compare two strings without leaking where they differ.\n *\n * Used for the app secret signature and for the subscription token: both are compared against a value the request\n * merely claims to know, so the comparison itself must not become an oracle.\n *\n * @param expected - the value computed from the request.\n * @param received - the value the request carried, if it carried one.\n * @returns whether the two are equal.\n */\nexport function constantTimeEqual(expected, received) {\n if (received === undefined)\n return false;\n const left = Buffer.from(expected, 'utf8');\n const right = Buffer.from(received, 'utf8');\n if (left.length !== right.length)\n return false;\n return timingSafeEqual(left, right);\n}\n/**\n * Whether a delivery carries the signature of `body`.\n *\n * @param secret - the App Secret.\n * @param body - the raw request body.\n * @param received - the header value, if the request carried one.\n * @returns whether the header matches.\n */\nexport function matchesSignature(secret, body, received) {\n return constantTimeEqual(signatureOf(secret, body), received);\n}\n//# sourceMappingURL=signature.js.map","/**\n * The webhook transport.\n *\n * The Cloud API has no long connection, polling or gateway: Meta posts every event to one public HTTPS callback, and\n * the subscription is confirmed once by a `GET` handshake on the same path. The route is registered on the profile's\n * `webServer`, which owns the listener and the public address; the adapter keeps the handler anonymous and\n * authenticates every delivery with the App Secret.\n *\n * A delivery is acknowledged only after intake stored every message it carries, so a retrying platform can resend a\n * delivery whose intake failed, and every refusal happens before any work is done.\n */\nimport { routePath } from \"../config.js\";\nimport { decodeChange } from \"../decode.js\";\nimport { constantTimeEqual, matchesSignature, SIGNATURE_HEADER, } from \"../signature.js\";\n/** Message of any caught value, for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/** One header of an inbound request, when it arrived exactly once. */\nfunction headerOf(request, name) {\n const value = request.headers[name];\n return typeof value === 'string' ? value : undefined;\n}\n/** One plain object. */\nfunction isRecord(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n/** Read a request body to its end. The platform publishes no delivery-size limit, so the adapter imposes none. */\nasync function readBody(request) {\n const chunks = [];\n for await (const chunk of request) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n }\n return Buffer.concat(chunks).toString('utf8');\n}\n/** Write one bodiless answer. */\nfunction writeStatus(response, status, headers = {}) {\n response.writeHead(status, headers);\n response.end();\n}\n/** Write one answer with a body. */\nfunction writeBody(response, status, body, contentType) {\n response.writeHead(status, { 'content-type': contentType });\n response.end(body);\n}\n/**\n * Whether a parsed JSON value is a delivery this handler can read.\n *\n * A change of the `messages` field carries the routing key, so its value is validated down to that key; every other\n * change family is only logged, so its value is taken as it came.\n * @param value - the parsed JSON value.\n * @returns whether the value is a webhook delivery.\n */\nfunction isWebhookBody(value) {\n if (!isRecord(value) ||\n typeof value.object !== 'string' ||\n !Array.isArray(value.entry))\n return false;\n for (const entry of value.entry) {\n if (!isRecord(entry) || !Array.isArray(entry.changes))\n return false;\n for (const change of entry.changes) {\n if (!isRecord(change) ||\n typeof change.field !== 'string' ||\n !isRecord(change.value))\n return false;\n if (change.field !== 'messages')\n continue;\n const current = change.value;\n if (!isRecord(current.metadata) ||\n typeof current.metadata.phone_number_id !== 'string')\n return false;\n if (current.messages !== undefined && !Array.isArray(current.messages))\n return false;\n if (current.statuses !== undefined && !Array.isArray(current.statuses))\n return false;\n }\n }\n return true;\n}\n/**\n * The webhook route.\n *\n * `start` registers the one route that answers both the handshake and every delivery; `stop` releases it.\n */\nexport class WhatsappWebhook {\n bot;\n webServer;\n dispose;\n constructor(bot, webServer) {\n this.bot = bot;\n this.webServer = webServer;\n }\n /** Register the route. */\n start() {\n this.dispose = this.webServer.register({\n kind: 'exact',\n path: routePath(this.bot.config.webhook.path),\n auth: 'anonymous',\n handler: (request, response) => this.handle(request, response),\n });\n }\n /** Release the route. */\n stop() {\n this.dispose?.();\n this.dispose = undefined;\n }\n async handle(request, response) {\n try {\n if (request.method === 'GET') {\n this.verify(request, response);\n return;\n }\n if (request.method !== 'POST') {\n writeStatus(response, 405, { allow: 'GET, POST' });\n return;\n }\n await this.deliver(request, response);\n }\n catch (error) {\n this.bot.ctx.logger.warn('whatsapp: webhook delivery failed: %s', messageOf(error));\n if (!response.headersSent)\n writeStatus(response, 500);\n else\n response.end();\n }\n }\n /**\n * The subscription handshake: `hub.mode` and `hub.verify_token` are checked, then `hub.challenge` is echoed.\n *\n * The token is a value a human typed into the Meta app panel, not a secret of the API surface, but it is compared in\n * constant time like the signature so the endpoint is not an oracle for it.\n */\n verify(request, response) {\n const query = new URL(request.url ?? '', 'http://localhost').searchParams;\n const mode = query.get('hub.mode');\n const challenge = query.get('hub.challenge');\n const token = query.get('hub.verify_token') ?? undefined;\n if (mode !== 'subscribe' ||\n challenge === null ||\n !constantTimeEqual(this.bot.config.verifyToken, token)) {\n writeStatus(response, 403);\n return;\n }\n writeBody(response, 200, challenge, 'text/plain');\n }\n /** Verify, parse and store one delivery. */\n async deliver(request, response) {\n // A request without a signature is not from Meta; there is no reason to read its body.\n const received = headerOf(request, SIGNATURE_HEADER);\n if (received === undefined) {\n writeStatus(response, 401);\n return;\n }\n const body = await readBody(request);\n // The signature covers the body as it arrived, so it is verified before the body is interpreted.\n if (!matchesSignature(this.bot.config.secret, body, received)) {\n writeStatus(response, 401);\n return;\n }\n let parsed;\n try {\n parsed = JSON.parse(body);\n }\n catch (error) {\n this.bot.ctx.logger.warn('whatsapp: cannot parse a webhook delivery: %s', messageOf(error));\n writeStatus(response, 400);\n return;\n }\n if (!isWebhookBody(parsed)) {\n this.bot.ctx.logger.warn('whatsapp: a webhook delivery is not a WhatsApp payload');\n writeStatus(response, 400);\n return;\n }\n if (parsed.object !== 'whatsapp_business_account') {\n // Another Meta product shares the app secret; its deliveries are none of this adapter's business.\n this.bot.ctx.logger.debug('whatsapp: ignoring a %s delivery', parsed.object);\n writeStatus(response, 200);\n return;\n }\n for (const entry of parsed.entry) {\n for (const change of entry.changes) {\n // One callback address serves every number of the app; each row answers only its own number.\n if (change.field === 'messages' &&\n change.value.metadata.phone_number_id !==\n this.bot.config.phoneNumberId) {\n this.bot.ctx.logger.debug('whatsapp: skipping a change of number %s', change.value.metadata.phone_number_id);\n continue;\n }\n for (const session of decodeChange(this.bot, change))\n await this.bot.receive(session);\n }\n }\n writeStatus(response, 200);\n }\n}\n//# sourceMappingURL=webhook.js.map","import { Adapter, PlatformError } from '@deepseek-ai/cordis-plugin-im-core';\nimport { Config, configError } from \"./config.js\";\nimport { classifyWhatsappError, WhatsappApiError } from \"./errors.js\";\nimport { fetchPhoneNumber, userOf, verifyIdentity } from \"./identity.js\";\nimport { Internal } from \"./internal.js\";\nimport { serveMedia } from \"./media.js\";\nimport { SUPPORTED_MEDIA } from \"./modes/shared.js\";\nimport { createTextMode } from \"./modes/text.js\";\nimport { WhatsAppRequest } from \"./request.js\";\nimport { createReaction, deleteReaction, sendPayload } from \"./send.js\";\nimport { WhatsappWebhook } from \"./transport/webhook.js\";\n/** Message of any caught value, for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/**\n * WhatsApp Cloud API adapter for one business phone number.\n *\n * The number is identified by configuration (`phoneNumberId`), confirmed with `GET /{phoneNumberId}` on connect. The\n * webhook is the only transport, `text` is the only mode, and every send is its own request: the platform has no\n * request that publishes several messages, no edit, no delete and no stream.\n *\n * The 24-hour customer service window is not tracked locally. A free-form message outside it is refused by the\n * platform (`131047`), which this adapter reports as an `invalid`, unpublished failure naming the template\n * requirement; no template message is sent by this version.\n */\nexport class WhatsappBot extends Adapter {\n /** The adapter needs the Satori service and the isolated `http` service. */\n static inject = ['satori', 'http'];\n /** The Loader applies this schema to a profile row's `config` before the constructor runs. */\n static Config = Config;\n modes;\n modeOrder = ['text'];\n /** The Graph client every call goes through. */\n request;\n /** The platform API map, exposed through `bot.internal`. */\n internal;\n webhook;\n constructor(ctx, config) {\n super(ctx, config, {\n id: `whatsapp:${config.phoneNumberId}`,\n platform: 'whatsapp',\n adapter: 'whatsapp',\n });\n // `bot.id` has to be fixed at construction, so the number is configured rather than discovered; `connect` proves\n // the token reaches it.\n this.selfId = config.phoneNumberId;\n this.request = new WhatsAppRequest(ctx, config);\n this.internal = new Internal(this.request);\n this.modes = { text: createTextMode(config) };\n this.defineInternalRoute('/assets/:mediaId', async ({ params }) => serveMedia(this, params.mediaId));\n }\n async connect() {\n const invalid = configError(this.config);\n if (invalid !== undefined) {\n this.ctx.logger.error('whatsapp: connect failed: %s', invalid.message);\n throw invalid;\n }\n const webServer = this.ctx.get('webServer');\n if (webServer === undefined) {\n const error = new Error('whatsapp: this adapter needs a profile-provided webServer; WhatsApp has only the webhook transport, so add a webServer row to the profile and expose its callback path over public HTTPS');\n this.ctx.logger.error(error.message);\n throw error;\n }\n try {\n const info = await fetchPhoneNumber(this.request, this.config.phoneNumberId);\n this.selfId = verifyIdentity(this.config.phoneNumberId, info);\n this.user = userOf(info);\n const webhook = new WhatsappWebhook(this, webServer);\n webhook.start();\n this.webhook = webhook;\n this.online();\n }\n catch (error) {\n // `Bot.start` only stores a connect failure on `bot.error`, so log it here.\n this.ctx.logger.error('whatsapp: connect failed: %s', messageOf(error));\n throw error;\n }\n }\n async disconnect() {\n const webhook = this.webhook;\n this.webhook = undefined;\n webhook?.stop();\n }\n /**\n * Turn one outbound attachment into the media id a message carries.\n *\n * The Cloud API uploads the bytes first and sends the message by id afterwards, so no staging is involved. A type\n * outside the platform's documented list is refused here instead of being dropped silently: the receipt has to say\n * that this attachment was not sent.\n */\n async upload(ref, _scope, ctx) {\n let fetched;\n try {\n fetched = await ctx.fetch(ref.src, ctx.signal);\n }\n catch (error) {\n // The bytes never reached a request: a source that cannot be read is a request-level failure, published: no.\n if (ctx.signal.aborted)\n throw error;\n throw new PlatformError('invalid', `whatsapp: media source ${ref.src} could not be read: ${messageOf(error)}`, {\n published: 'no',\n cause: error,\n });\n }\n const mime = ref.meta.mime ?? fetched.mime;\n const name = ref.meta.name ?? fetched.name ?? 'file';\n if (mime === undefined || !SUPPORTED_MEDIA.includes(mime)) {\n throw new PlatformError('invalid', `whatsapp: the platform does not accept ${mime ?? 'an unspecified media type'} ` +\n `(${ref.src}); supported types are ${SUPPORTED_MEDIA.join(', ')}`, { code: 'whatsapp-unsupported-media-type', published: 'no' });\n }\n const form = new FormData();\n form.append('file', new Blob([fetched.data], { type: mime }), name);\n form.append('type', mime);\n form.append('messaging_product', 'whatsapp');\n const answer = await this.internal.uploadMedia(this.selfId, form);\n return {\n key: answer.id,\n extra: { name, mime, size: fetched.data.byteLength },\n };\n }\n resourceScope(_target, _kind) {\n // A media id belongs to the number and is reusable from any chat.\n return this.id;\n }\n async sendPayload(payload, target, ctx) {\n return await this.call(() => sendPayload(this.deps(), payload, target, ctx));\n }\n async createReaction(message, emoji) {\n await this.call(() => createReaction(this.deps(), message, emoji));\n }\n async deleteReaction(message, emoji) {\n await this.call(() => deleteReaction(this.deps(), message, emoji));\n }\n classify(error) {\n return classifyWhatsappError(error);\n }\n deps() {\n return { selfId: this.selfId, internal: this.internal };\n }\n /**\n * Run one outbound call, naming a revoked token in the log.\n *\n * A token rejected at runtime (`190`) leaves the webhook working while every send fails, and nothing else surfaces\n * that state: the request itself only reaches the caller of this send.\n *\n * @param operation - the outbound call.\n * @returns what the call answered.\n */\n async call(operation) {\n try {\n return await operation();\n }\n catch (error) {\n if (error instanceof WhatsappApiError && error.code === 190) {\n this.ctx.logger.error('whatsapp: the system user token was rejected; webhook intake continues but every send fails: %s', error.message);\n }\n throw error;\n }\n }\n}\nexport { Config };\nexport default WhatsappBot;\n//# sourceMappingURL=bot.js.map"],"mappings":";;;;;;AAEA,MAAa,SAAS,EAAE,OAAO;CAC3B,eAAe,EAAE,OAAO,CAAC,CAAC,SAAS;CACnC,aAAa,EAAE,OAAO,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,SAAS;CAChD,aAAa,EAAE,OAAO,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,SAAS;CAChD,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,SAAS;CAC3C,Y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AAM,UAAU;EAC3B,SACO,OAAO;GACV,IAAI,iBAAiB,oBAAoB,MAAM,SAAS,KACpD,KAAK,IAAI,OAAO,MAAM,mGAAmG,MAAM,OAAO;GAE1I,MAAM;EACV;CACJ;AACJ"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Adapter, PlatformError } from '@deepseek-ai/cordis-plugin-im-core';
|
|
2
|
+
import type { MessageRef, Mode, PrepareContext, ResolvedResource, ResourceKind, ResourceRef, SendContext, SentPart, Target } from '@deepseek-ai/cordis-plugin-im-core';
|
|
3
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
4
|
+
import { Config } from './config.ts';
|
|
5
|
+
import { Internal } from './internal.ts';
|
|
6
|
+
import type { WhatsappModeTypes } from './modes/shared.ts';
|
|
7
|
+
import { WhatsAppRequest } from './request.ts';
|
|
8
|
+
/** The single mode this adapter always registers. */
|
|
9
|
+
export interface WhatsappModes {
|
|
10
|
+
[mode: string]: Mode<WhatsappModeTypes>;
|
|
11
|
+
text: Mode<WhatsappModeTypes>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* WhatsApp Cloud API adapter for one business phone number.
|
|
15
|
+
*
|
|
16
|
+
* The number is identified by configuration (`phoneNumberId`), confirmed with `GET /{phoneNumberId}` on connect. The
|
|
17
|
+
* webhook is the only transport, `text` is the only mode, and every send is its own request: the platform has no
|
|
18
|
+
* request that publishes several messages, no edit, no delete and no stream.
|
|
19
|
+
*
|
|
20
|
+
* The 24-hour customer service window is not tracked locally. A free-form message outside it is refused by the
|
|
21
|
+
* platform (`131047`), which this adapter reports as an `invalid`, unpublished failure naming the template
|
|
22
|
+
* requirement; no template message is sent by this version.
|
|
23
|
+
*/
|
|
24
|
+
export declare class WhatsappBot extends Adapter<Config, WhatsappModes> {
|
|
25
|
+
/** The adapter needs the Satori service and the isolated `http` service. */
|
|
26
|
+
static inject: string[];
|
|
27
|
+
/** The Loader applies this schema to a profile row's `config` before the constructor runs. */
|
|
28
|
+
static readonly Config: import("@deepseek-ai/schemastery").default<Config>;
|
|
29
|
+
readonly modes: WhatsappModes;
|
|
30
|
+
readonly modeOrder: readonly ["text"];
|
|
31
|
+
/** The Graph client every call goes through. */
|
|
32
|
+
readonly request: WhatsAppRequest;
|
|
33
|
+
/** The platform API map, exposed through `bot.internal`. */
|
|
34
|
+
readonly internal: Internal;
|
|
35
|
+
private webhook;
|
|
36
|
+
constructor(ctx: Context, config: Config);
|
|
37
|
+
connect(): Promise<void>;
|
|
38
|
+
disconnect(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Turn one outbound attachment into the media id a message carries.
|
|
41
|
+
*
|
|
42
|
+
* The Cloud API uploads the bytes first and sends the message by id afterwards, so no staging is involved. A type
|
|
43
|
+
* outside the platform's documented list is refused here instead of being dropped silently: the receipt has to say
|
|
44
|
+
* that this attachment was not sent.
|
|
45
|
+
*/
|
|
46
|
+
upload(ref: ResourceRef, _scope: string, ctx: PrepareContext): Promise<ResolvedResource>;
|
|
47
|
+
resourceScope(_target: Target, _kind: ResourceKind): string;
|
|
48
|
+
sendPayload(payload: unknown, target: Target, ctx: SendContext): Promise<SentPart>;
|
|
49
|
+
createReaction(message: MessageRef, emoji: string): Promise<void>;
|
|
50
|
+
deleteReaction(message: MessageRef, emoji: string): Promise<void>;
|
|
51
|
+
classify(error: unknown): PlatformError;
|
|
52
|
+
private deps;
|
|
53
|
+
/**
|
|
54
|
+
* Run one outbound call, naming a revoked token in the log.
|
|
55
|
+
*
|
|
56
|
+
* A token rejected at runtime (`190`) leaves the webhook working while every send fails, and nothing else surfaces
|
|
57
|
+
* that state: the request itself only reaches the caller of this send.
|
|
58
|
+
*
|
|
59
|
+
* @param operation - the outbound call.
|
|
60
|
+
* @returns what the call answered.
|
|
61
|
+
*/
|
|
62
|
+
private call;
|
|
63
|
+
}
|
|
64
|
+
export { Config };
|
|
65
|
+
export default WhatsappBot;
|
|
66
|
+
//# sourceMappingURL=bot.d.ts.map
|
|
@@ -0,0 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I,CAAC;IAgCxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAM1C;;;;;;OAMG;IACY,MAAM,CACnB,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,gBAAgB,CAAC;IAqCnB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM;IAKrD,WAAW,CACxB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,QAAQ,CAAC;IAML,cAAc,CAC3B,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAID,cAAc,CAC3B,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAIP,QAAQ,CAAC,KAAK,EAAE,OAAO;IAIhC,OAAO,CAAC,IAAI;IAIZ;;;;;;;;OAQG;YACW,IAAI;CAanB;AAED,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,eAAe,WAAW,CAAA"}
|
package/lib/types/bot.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Adapter, PlatformError } from '@deepseek-ai/cordis-plugin-im-core';
|
|
2
|
+
import { Config, configError } from "./config.js";
|
|
3
|
+
import { classifyWhatsappError, WhatsappApiError } from "./errors.js";
|
|
4
|
+
import { fetchPhoneNumber, userOf, verifyIdentity } from "./identity.js";
|
|
5
|
+
import { Internal } from "./internal.js";
|
|
6
|
+
import { serveMedia } from "./media.js";
|
|
7
|
+
import { SUPPORTED_MEDIA } from "./modes/shared.js";
|
|
8
|
+
import { createTextMode } from "./modes/text.js";
|
|
9
|
+
import { WhatsAppRequest } from "./request.js";
|
|
10
|
+
import { createReaction, deleteReaction, sendPayload } from "./send.js";
|
|
11
|
+
import { WhatsappWebhook } from "./transport/webhook.js";
|
|
12
|
+
/** Message of any caught value, for a log line. */
|
|
13
|
+
function messageOf(error) {
|
|
14
|
+
return error instanceof Error ? error.message : String(error);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* WhatsApp Cloud API adapter for one business phone number.
|
|
18
|
+
*
|
|
19
|
+
* The number is identified by configuration (`phoneNumberId`), confirmed with `GET /{phoneNumberId}` on connect. The
|
|
20
|
+
* webhook is the only transport, `text` is the only mode, and every send is its own request: the platform has no
|
|
21
|
+
* request that publishes several messages, no edit, no delete and no stream.
|
|
22
|
+
*
|
|
23
|
+
* The 24-hour customer service window is not tracked locally. A free-form message outside it is refused by the
|
|
24
|
+
* platform (`131047`), which this adapter reports as an `invalid`, unpublished failure naming the template
|
|
25
|
+
* requirement; no template message is sent by this version.
|
|
26
|
+
*/
|
|
27
|
+
export class WhatsappBot extends Adapter {
|
|
28
|
+
/** The adapter needs the Satori service and the isolated `http` service. */
|
|
29
|
+
static inject = ['satori', 'http'];
|
|
30
|
+
/** The Loader applies this schema to a profile row's `config` before the constructor runs. */
|
|
31
|
+
static Config = Config;
|
|
32
|
+
modes;
|
|
33
|
+
modeOrder = ['text'];
|
|
34
|
+
/** The Graph client every call goes through. */
|
|
35
|
+
request;
|
|
36
|
+
/** The platform API map, exposed through `bot.internal`. */
|
|
37
|
+
internal;
|
|
38
|
+
webhook;
|
|
39
|
+
constructor(ctx, config) {
|
|
40
|
+
super(ctx, config, {
|
|
41
|
+
id: `whatsapp:${config.phoneNumberId}`,
|
|
42
|
+
platform: 'whatsapp',
|
|
43
|
+
adapter: 'whatsapp',
|
|
44
|
+
});
|
|
45
|
+
// `bot.id` has to be fixed at construction, so the number is configured rather than discovered; `connect` proves
|
|
46
|
+
// the token reaches it.
|
|
47
|
+
this.selfId = config.phoneNumberId;
|
|
48
|
+
this.request = new WhatsAppRequest(ctx, config);
|
|
49
|
+
this.internal = new Internal(this.request);
|
|
50
|
+
this.modes = { text: createTextMode(config) };
|
|
51
|
+
this.defineInternalRoute('/assets/:mediaId', async ({ params }) => serveMedia(this, params.mediaId));
|
|
52
|
+
}
|
|
53
|
+
async connect() {
|
|
54
|
+
const invalid = configError(this.config);
|
|
55
|
+
if (invalid !== undefined) {
|
|
56
|
+
this.ctx.logger.error('whatsapp: connect failed: %s', invalid.message);
|
|
57
|
+
throw invalid;
|
|
58
|
+
}
|
|
59
|
+
const webServer = this.ctx.get('webServer');
|
|
60
|
+
if (webServer === undefined) {
|
|
61
|
+
const error = new Error('whatsapp: this adapter needs a profile-provided webServer; WhatsApp has only the webhook transport, so add a webServer row to the profile and expose its callback path over public HTTPS');
|
|
62
|
+
this.ctx.logger.error(error.message);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const info = await fetchPhoneNumber(this.request, this.config.phoneNumberId);
|
|
67
|
+
this.selfId = verifyIdentity(this.config.phoneNumberId, info);
|
|
68
|
+
this.user = userOf(info);
|
|
69
|
+
const webhook = new WhatsappWebhook(this, webServer);
|
|
70
|
+
webhook.start();
|
|
71
|
+
this.webhook = webhook;
|
|
72
|
+
this.online();
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// `Bot.start` only stores a connect failure on `bot.error`, so log it here.
|
|
76
|
+
this.ctx.logger.error('whatsapp: connect failed: %s', messageOf(error));
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async disconnect() {
|
|
81
|
+
const webhook = this.webhook;
|
|
82
|
+
this.webhook = undefined;
|
|
83
|
+
webhook?.stop();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Turn one outbound attachment into the media id a message carries.
|
|
87
|
+
*
|
|
88
|
+
* The Cloud API uploads the bytes first and sends the message by id afterwards, so no staging is involved. A type
|
|
89
|
+
* outside the platform's documented list is refused here instead of being dropped silently: the receipt has to say
|
|
90
|
+
* that this attachment was not sent.
|
|
91
|
+
*/
|
|
92
|
+
async upload(ref, _scope, ctx) {
|
|
93
|
+
let fetched;
|
|
94
|
+
try {
|
|
95
|
+
fetched = await ctx.fetch(ref.src, ctx.signal);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
// The bytes never reached a request: a source that cannot be read is a request-level failure, published: no.
|
|
99
|
+
if (ctx.signal.aborted)
|
|
100
|
+
throw error;
|
|
101
|
+
throw new PlatformError('invalid', `whatsapp: media source ${ref.src} could not be read: ${messageOf(error)}`, {
|
|
102
|
+
published: 'no',
|
|
103
|
+
cause: error,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const mime = ref.meta.mime ?? fetched.mime;
|
|
107
|
+
const name = ref.meta.name ?? fetched.name ?? 'file';
|
|
108
|
+
if (mime === undefined || !SUPPORTED_MEDIA.includes(mime)) {
|
|
109
|
+
throw new PlatformError('invalid', `whatsapp: the platform does not accept ${mime ?? 'an unspecified media type'} ` +
|
|
110
|
+
`(${ref.src}); supported types are ${SUPPORTED_MEDIA.join(', ')}`, { code: 'whatsapp-unsupported-media-type', published: 'no' });
|
|
111
|
+
}
|
|
112
|
+
const form = new FormData();
|
|
113
|
+
form.append('file', new Blob([fetched.data], { type: mime }), name);
|
|
114
|
+
form.append('type', mime);
|
|
115
|
+
form.append('messaging_product', 'whatsapp');
|
|
116
|
+
const answer = await this.internal.uploadMedia(this.selfId, form);
|
|
117
|
+
return {
|
|
118
|
+
key: answer.id,
|
|
119
|
+
extra: { name, mime, size: fetched.data.byteLength },
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
resourceScope(_target, _kind) {
|
|
123
|
+
// A media id belongs to the number and is reusable from any chat.
|
|
124
|
+
return this.id;
|
|
125
|
+
}
|
|
126
|
+
async sendPayload(payload, target, ctx) {
|
|
127
|
+
return await this.call(() => sendPayload(this.deps(), payload, target, ctx));
|
|
128
|
+
}
|
|
129
|
+
async createReaction(message, emoji) {
|
|
130
|
+
await this.call(() => createReaction(this.deps(), message, emoji));
|
|
131
|
+
}
|
|
132
|
+
async deleteReaction(message, emoji) {
|
|
133
|
+
await this.call(() => deleteReaction(this.deps(), message, emoji));
|
|
134
|
+
}
|
|
135
|
+
classify(error) {
|
|
136
|
+
return classifyWhatsappError(error);
|
|
137
|
+
}
|
|
138
|
+
deps() {
|
|
139
|
+
return { selfId: this.selfId, internal: this.internal };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Run one outbound call, naming a revoked token in the log.
|
|
143
|
+
*
|
|
144
|
+
* A token rejected at runtime (`190`) leaves the webhook working while every send fails, and nothing else surfaces
|
|
145
|
+
* that state: the request itself only reaches the caller of this send.
|
|
146
|
+
*
|
|
147
|
+
* @param operation - the outbound call.
|
|
148
|
+
* @returns what the call answered.
|
|
149
|
+
*/
|
|
150
|
+
async call(operation) {
|
|
151
|
+
try {
|
|
152
|
+
return await operation();
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (error instanceof WhatsappApiError && error.code === 190) {
|
|
156
|
+
this.ctx.logger.error('whatsapp: the system user token was rejected; webhook intake continues but every send fails: %s', error.message);
|
|
157
|
+
}
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export { Config };
|
|
163
|
+
export default WhatsappBot;
|
|
164
|
+
//# sourceMappingURL=bot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot.js","sourceRoot":"","sources":["../../src/bot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAa3E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE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,CAC3B,OAAmB,EACnB,KAAa;QAEb,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IACpE,CAAC;IAEQ,KAAK,CAAC,cAAc,CAC3B,OAAmB,EACnB,KAAa;QAEb,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IACpE,CAAC;IAEQ,QAAQ,CAAC,KAAc;QAC9B,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAA;IACrC,CAAC;IAEO,IAAI;QACV,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAA;IACzD,CAAC;IAED;;;;;;;;OAQG;IACK,KAAK,CAAC,IAAI,CAAI,SAA2B;QAC/C,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,EAAE,CAAA;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;gBAC5D,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CACnB,iGAAiG,EACjG,KAAK,CAAC,OAAO,CACd,CAAA;YACH,CAAC;YACD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;;AAGH,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,eAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import z from '@deepseek-ai/schemastery';
|
|
2
|
+
/** One WhatsApp Cloud API phone number. */
|
|
3
|
+
export interface Config {
|
|
4
|
+
/** Graph id of the phone number (`metadata.phone_number_id` of every webhook, and the `{phoneNumberId}` of every call). */
|
|
5
|
+
phoneNumberId: string;
|
|
6
|
+
/** System user token: the `Authorization: Bearer` value of every Graph call. */
|
|
7
|
+
systemToken: string;
|
|
8
|
+
/** The `hub.verify_token` the subscription handshake must present; chosen by hand in the Meta app panel. */
|
|
9
|
+
verifyToken: string;
|
|
10
|
+
/** App Secret: the HMAC key of `X-Hub-Signature-256`; no API call uses it. */
|
|
11
|
+
secret: string;
|
|
12
|
+
/** Graph API root; pin a version by writing `https://graph.facebook.com/v21.0`. */
|
|
13
|
+
apiBaseUrl: string;
|
|
14
|
+
webhook: {
|
|
15
|
+
/** Inbound webhook path: absolute, no trailing slash. */
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
/** Whether a text message asks the client to render a link preview (`text.preview_url`). */
|
|
19
|
+
linkPreview: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Validated WhatsApp adapter configuration. */
|
|
22
|
+
export declare const Config: z<Config>;
|
|
23
|
+
/**
|
|
24
|
+
* Normalize a route path: absolute, no trailing slash.
|
|
25
|
+
*
|
|
26
|
+
* @param path - a configured path.
|
|
27
|
+
* @returns the pathname to register on the web server.
|
|
28
|
+
*/
|
|
29
|
+
export declare function routePath(path: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* The configuration the adapter cannot work from, as far as it can tell locally.
|
|
32
|
+
*
|
|
33
|
+
* WhatsApp has only the webhook transport, so a profile without a usable callback path receives nothing; the check
|
|
34
|
+
* runs when the bot starts, not on the first delivery.
|
|
35
|
+
*
|
|
36
|
+
* @param config - the validated configuration.
|
|
37
|
+
* @returns the configuration error, or undefined when the configuration is usable.
|
|
38
|
+
*/
|
|
39
|
+
export declare function configError(config: Config): Error | undefined;
|
|
40
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,2CAA2C;AAC3C,MAAM,WAAW,MAAM;IACrB,2HAA2H;IAC3H,aAAa,EAAE,MAAM,CAAA;IACrB,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAA;IACnB,4GAA4G;IAC5G,WAAW,EAAE,MAAM,CAAA;IACnB,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAA;IACd,mFAAmF;IACnF,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE;QACP,yDAAyD;QACzD,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,4FAA4F;IAC5F,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,gDAAgD;AAChD,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAY3B,CAAA;AAEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAwC7D"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import z from '@deepseek-ai/schemastery';
|
|
2
|
+
/** Validated WhatsApp adapter configuration. */
|
|
3
|
+
export const Config = z.object({
|
|
4
|
+
phoneNumberId: z.string().required(),
|
|
5
|
+
systemToken: z.string().role('secret').required(),
|
|
6
|
+
verifyToken: z.string().role('secret').required(),
|
|
7
|
+
secret: z.string().role('secret').required(),
|
|
8
|
+
apiBaseUrl: z.string().role('url').default('https://graph.facebook.com'),
|
|
9
|
+
webhook: z
|
|
10
|
+
.object({
|
|
11
|
+
path: z.string().default('/whatsapp'),
|
|
12
|
+
})
|
|
13
|
+
.default({}),
|
|
14
|
+
linkPreview: z.boolean().default(true),
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Normalize a route path: absolute, no trailing slash.
|
|
18
|
+
*
|
|
19
|
+
* @param path - a configured path.
|
|
20
|
+
* @returns the pathname to register on the web server.
|
|
21
|
+
*/
|
|
22
|
+
export function routePath(path) {
|
|
23
|
+
const withSlash = path.startsWith('/') ? path : `/${path}`;
|
|
24
|
+
return withSlash.length > 1 ? withSlash.replace(/\/+$/, '') : withSlash;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The configuration the adapter cannot work from, as far as it can tell locally.
|
|
28
|
+
*
|
|
29
|
+
* WhatsApp has only the webhook transport, so a profile without a usable callback path receives nothing; the check
|
|
30
|
+
* runs when the bot starts, not on the first delivery.
|
|
31
|
+
*
|
|
32
|
+
* @param config - the validated configuration.
|
|
33
|
+
* @returns the configuration error, or undefined when the configuration is usable.
|
|
34
|
+
*/
|
|
35
|
+
export function configError(config) {
|
|
36
|
+
if (config.phoneNumberId === '') {
|
|
37
|
+
return new Error('whatsapp: phoneNumberId is required (the Graph id of the phone number, from the Meta app WhatsApp API setup)');
|
|
38
|
+
}
|
|
39
|
+
if (config.systemToken === '') {
|
|
40
|
+
return new Error('whatsapp: systemToken is required (the system user token that authenticates every Graph call)');
|
|
41
|
+
}
|
|
42
|
+
if (config.verifyToken === '') {
|
|
43
|
+
return new Error('whatsapp: verifyToken is required (the subscription handshake compares it with hub.verify_token)');
|
|
44
|
+
}
|
|
45
|
+
if (config.secret === '') {
|
|
46
|
+
return new Error('whatsapp: secret is required (the App Secret; it verifies X-Hub-Signature-256 of every delivery)');
|
|
47
|
+
}
|
|
48
|
+
if (config.apiBaseUrl === '') {
|
|
49
|
+
return new Error('whatsapp: apiBaseUrl is required (the Graph API root, https://graph.facebook.com by default)');
|
|
50
|
+
}
|
|
51
|
+
let origin;
|
|
52
|
+
try {
|
|
53
|
+
origin = new URL(config.apiBaseUrl);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return new Error(`whatsapp: apiBaseUrl must be an absolute URL, got "${config.apiBaseUrl}"`);
|
|
57
|
+
}
|
|
58
|
+
if (origin.protocol !== 'https:') {
|
|
59
|
+
return new Error(`whatsapp: apiBaseUrl must be an https URL, got "${config.apiBaseUrl}" (every Graph call carries a bearer token)`);
|
|
60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