NodeOPCUA API Documentation
    Preparing search index...

    Class SecureChunkWriter

    Chunks the messages of a secure channel (OPC 10000-6 6.7.2): the symmetric ones (MSG, CLO) of one token, and OpenSecureChannel with its asymmetric security header and RSA encryption. Everything that does not change between messages (chunk size, header layout, keys, block sizes, signature length, limits) is set once, and writing a message is one call, with no event and no per-message object besides the chunks.

    The body is encoded once, after room left for the headers. Each chunk then gets its own buffer (the transport keeps it; the encode buffer serves the next message), its headers, its slice of the body, and, as the channel's security requires, its padding, signature and encryption. One chunk is the n = 1 case of the same loop.

    A signature produced by a remote (HSM/KMS) provider is asynchronous: writeMessageAsync.

    Index
    channelId: number
    chunkSize: number
    cipherBlockSize: number

    equal to plainBlockSize for symmetric encryption, larger for RSA

    maxBodySizePerChunk: number

    the largest body that fits one chunk

    maxChunkCount: number
    maxMessageSize: number
    plainBlockSize: number

    0 when the chunks are not encrypted

    securityMode: MessageSecurityMode
    signatureLength: number
    tokenId: number

    the token of a symmetric writer, 0 for an asymmetric one

    defaultMaxMessageSize: number

    growth cap of the encode buffer when no maximum message size is negotiated

    maxRetainedEncodeBufferSize: number

    the largest encode buffer kept from one message to the next

    minimumMessageSizeHint: number

    floor for the encode buffer, so tiny messages do not keep reallocating

    • encodes message once, writes it as one or more chunks and hands each chunk to send, in order, before returning. Returns BadTcpMessageTooLarge and sends nothing when the message exceeds maxMessageSize or maxChunkCount. A writer that signs asynchronously needs writeMessageAsync.

      Parameters

      • msgType: string
      • requestId: number
      • message: BaseUAObject
      • send: (chunk: Buffer) => void

      Returns StatusCode

    • writeMessage for a signature produced asynchronously (a key held by a remote HSM/KMS provider): the headers and sequence numbers of every chunk are written at once, in order; the chunks are handed to send, in order, once all of them are signed and encrypted. A signing failure rejects and sends nothing.

      Parameters

      • msgType: string
      • requestId: number
      • message: BaseUAObject
      • send: (chunk: Buffer) => void

      Returns Promise<StatusCode>

    • the body one chunk carries: the formulas of ChunkManager, which the bytes on the wire depend on (with encryption, whole cipher blocks after the headers, less the sequence header, the signature and the padding size bytes)

      Parameters

      • headerSize: number
      • chunkSize: number
      • signatureLength: number
      • plainBlockSize: number
      • cipherBlockSize: number

      Returns number

    • the size of the message header and of this security header

      Parameters

      Returns number

    • whether a writer can chunk messages in this mode with these functions, the combinations the chunk managers accepted: no security; or a signer (synchronous or asynchronous, never both) with a signature length, or neither; and encryption that does not shrink the data, required by SignAndEncrypt and applied in Sign too when given (OpenSecureChannel is encrypted in both).

      Parameters

      Returns boolean