How to use the node-opcua-chunkmanager.SequenceHeader function in node-opcua-chunkmanager

To help you get started, we’ve selected a few node-opcua-chunkmanager examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / secure_message_chunk_manager.ts View on Github external
// Note: OPCUA requires that chunkSize is at least 8192
        this.chunkSize = options.chunkSize || 1024 * 128;

        this.msgType = msgType;

        options.channelId = options.channelId || 0;
        assert(_.isFinite(options.channelId));
        this.channelId = options.channelId;

        const requestId = options.requestId;

        this.sequenceNumberGenerator = sequenceNumberGenerator;

        assert(requestId > 0, "expecting a valid request ID");

        this.sequenceHeader = new SequenceHeader({requestId, sequenceNumber: -1});

        const securityHeaderSize = this.securityHeader.binaryStoreSize();
        const sequenceHeaderSize = this.sequenceHeader.binaryStoreSize();
        assert(sequenceHeaderSize === 8);

        this.sequenceHeaderSize = sequenceHeaderSize;
        this.headerSize = 12 + securityHeaderSize;

        const params: IChunkManagerOptions = {
            chunkSize: this.chunkSize,

            headerSize: this.headerSize,
            writeHeaderFunc: (buffer: Buffer, isLast: boolean, totalLength: number) => {
                let finalC = isLast ? "F" : "C";
                finalC = this.aborted ? "A" : finalC;
                this.write_header(finalC, buffer, totalLength);
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / message_builder.ts View on Github external
} else {

            this.securityHeader = chooseSecurityHeader(msgType);
            this.securityHeader.decode(binaryStream);

            if (msgType === "OPN") {
                const asymmetricAlgorithmSecurityHeader = this.securityHeader as AsymmetricAlgorithmSecurityHeader;
                this.securityPolicy = fromURI(asymmetricAlgorithmSecurityHeader.securityPolicyUri);
                this.cryptoFactory = getCryptoFactory(this.securityPolicy);
            }

            if (!this._decrypt(binaryStream)) {
                return false;
            }

            this.sequenceHeader = new SequenceHeader();
            this.sequenceHeader.decode(binaryStream);

            /* istanbul ignore next */
            if (doDebug) {
                debugLog(" Sequence Header", this.sequenceHeader);
            }

            this._validateSequenceNumber(this.sequenceHeader.sequenceNumber);
        }
        return true;
    }
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / message_header_to_string.ts View on Github external
export function messageHeaderToString(messageChunk: Buffer): string {

    const stream = new BinaryStream(messageChunk);

    const messageHeader = readMessageHeader(stream);
    if (messageHeader.msgType === "ERR" || messageHeader.msgType === "HEL") {
        return messageHeader.msgType + " " + messageHeader.isFinal + " length   = " + messageHeader.length;
    }

    const securityHeader = chooseSecurityHeader(messageHeader.msgType);

    const sequenceHeader = new SequenceHeader();
    assert(stream.length === 8);

    const channelId = stream.readUInt32();
    securityHeader.decode(stream);
    sequenceHeader.decode(stream);

    const slice = messageChunk.slice(0, stream.length);

    return messageHeader.msgType + " " +
        messageHeader.isFinal +
        " length   = " + messageHeader.length +
        " channel  = " + channelId +
        " seqNum   = " + sequenceHeader.sequenceNumber +
        " req ID   = " + sequenceHeader.requestId +
        " security   = " + securityHeader.toString() +
        "\n\n" + hexDump(slice);

node-opcua-chunkmanager

pure nodejs OPCUA SDK - module chunkmanager

MIT
Latest version published 7 days ago

Package Health Score

83 / 100
Full package analysis