Skip to content

AS2MimeNode default boundaryPrefix produces 4-hyphen MIME boundary delimiters, violating RFC 2046 #3

@rubber-side-down

Description

@rubber-side-down

Bug: MIME boundary value defaults to --LibAs2 prefix, producing 4-hyphen delimiters in message body

Package: @mistweaverco/libas2

Description

AS2MimeNode sets boundaryPrefix to '--LibAs2' by default. Because RFC 2046 requires each boundary delimiter in the body to be -- followed by the boundary value, the resulting delimiters start with ---- (4 hyphens) rather than the required -- (2 hyphens). Many AS2 trading partners reject these messages.

Steps to reproduce

import { AS2Composer } from '@mistweaverco/libas2'

const composer = new AS2Composer({
  message: { filename: 'message.xml', contentType: 'application/xml', content: Buffer.from('<test/>') },
  agreement: {
    host:    { name: 'Host',    id: 'HOST',    url: 'http://host/as2',    sign: 'sha-256', certificate: HOST_CERT, privateKey: HOST_KEY },
    partner: { name: 'Partner', id: 'PARTNER', url: 'http://partner/as2', encrypt: false },
  },
})

const { headers, body } = await (await composer.compile()).buildObject()
console.log(headers['Content-Type'])
// multipart/signed; boundary="--LibAs2-abc123-Part_1"  ← boundary value starts with '--'
console.log(body.split('\n')[0])
// ----LibAs2-abc123-Part_1                             ← delimiter has 4 hyphens

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions