/** * JSON-safe extractors for XMTP's native remote-attachment content types. * * Native bindings hand `secret`/`salt`/`nonce` to JS as `Uint8Array`s. * `JSON.stringify` turns those into `{}` (or an indexed-object dump on * some Node versions), which is useless to a downstream agent. These * helpers re-encode the byte fields as **base64**, matching the encoding * the `agent serve` `remote-attach` stdin command already uses, so an * agent receives and sends remote attachments through one mental model. * * Decode-only — there is no `Codec` class here because the codec is * registered by the underlying `@xmtp/node-bindings` library and the * SDK already decodes these messages into the typed objects below. * These helpers just normalize them to a stable wire shape. */ import { type DecodedMessage } from "@xmtp/node-sdk"; /** JSON-safe view of a single `RemoteAttachmentInfo`. */ export interface RemoteAttachmentInfoJson { url: string; contentDigest: string; scheme: string; /** base64 of the encryption secret. */ secret: string; /** base64 of the encryption salt. */ salt: string; /** base64 of the encryption nonce. */ nonce: string; contentLength?: number; filename?: string; } /** JSON-safe view of a `RemoteAttachment` message payload. */ export type RemoteAttachmentJson = RemoteAttachmentInfoJson; /** JSON-safe view of a `MultiRemoteAttachment` message payload. */ export interface MultiRemoteAttachmentJson { attachments: RemoteAttachmentInfoJson[]; } /** * If the message is a single `xmtp.org/remoteStaticAttachment:1.0`, return * the JSON-safe extraction; otherwise undefined. */ export declare function extractRemoteAttachment(message: DecodedMessage): RemoteAttachmentJson | undefined; /** * If the message is a `xmtp.org/multiRemoteStaticAttachment:1.0`, return * the JSON-safe extraction; otherwise undefined. */ export declare function extractMultiRemoteAttachment(message: DecodedMessage): MultiRemoteAttachmentJson | undefined;