@xmtp/content-type-remote-attachment
Version:
An XMTP content type to support sending file attachments that are stored off network
78 lines (74 loc) • 2.56 kB
TypeScript
import { ContentTypeId, ContentCodec, EncodedContent, CodecRegistry } from '@xmtp/content-type-primitives';
declare const ContentTypeAttachment: ContentTypeId;
type Attachment = {
filename: string;
mimeType: string;
data: Uint8Array;
};
type AttachmentParameters = {
filename: string;
mimeType: string;
};
declare class AttachmentCodec implements ContentCodec<Attachment, AttachmentParameters> {
get contentType(): ContentTypeId;
encode(content: Attachment): {
type: ContentTypeId;
parameters: {
filename: string;
mimeType: string;
};
content: Uint8Array<ArrayBufferLike>;
};
decode(content: EncodedContent<AttachmentParameters>): Attachment;
fallback(content: Attachment): string | undefined;
shouldPush(): boolean;
}
declare const ContentTypeRemoteAttachment: ContentTypeId;
type EncryptedEncodedContent = {
digest: string;
salt: Uint8Array;
nonce: Uint8Array;
secret: Uint8Array;
payload: Uint8Array;
};
type RemoteAttachment = {
url: string;
contentDigest: string;
salt: Uint8Array;
nonce: Uint8Array;
secret: Uint8Array;
scheme: string;
contentLength: number;
filename: string;
};
type RemoteAttachmentParameters = {
contentDigest: string;
salt: string;
nonce: string;
secret: string;
scheme: string;
contentLength: string;
filename: string;
};
declare class RemoteAttachmentCodec implements ContentCodec<RemoteAttachment, RemoteAttachmentParameters> {
static load<T = unknown>(remoteAttachment: RemoteAttachment, codecRegistry: CodecRegistry): Promise<T>;
static encodeEncrypted<T>(content: T, codec: ContentCodec<T>): Promise<EncryptedEncodedContent>;
get contentType(): ContentTypeId;
encode(content: RemoteAttachment): {
type: ContentTypeId;
parameters: {
contentDigest: string;
salt: string;
nonce: string;
secret: string;
scheme: string;
contentLength: string;
filename: string;
};
content: Uint8Array<ArrayBufferLike>;
};
decode(content: EncodedContent<RemoteAttachmentParameters>): RemoteAttachment;
fallback(content: RemoteAttachment): string | undefined;
shouldPush(): boolean;
}
export { type Attachment, AttachmentCodec, type AttachmentParameters, ContentTypeAttachment, ContentTypeRemoteAttachment, type EncryptedEncodedContent, type RemoteAttachment, RemoteAttachmentCodec, type RemoteAttachmentParameters };