node-opcua-chunkmanager
Advanced tools
Comparing version 2.49.0 to 2.51.0
@@ -13,5 +13,5 @@ "use strict"; | ||
function verify_message_chunk(messageChunk) { | ||
node_opcua_assert_1.assert(messageChunk); | ||
node_opcua_assert_1.assert(messageChunk instanceof Buffer); | ||
const header = read_message_header_1.readMessageHeader(new node_opcua_binary_stream_1.BinaryStream(messageChunk)); | ||
(0, node_opcua_assert_1.assert)(messageChunk); | ||
(0, node_opcua_assert_1.assert)(messageChunk instanceof Buffer); | ||
const header = (0, read_message_header_1.readMessageHeader)(new node_opcua_binary_stream_1.BinaryStream(messageChunk)); | ||
if (messageChunk.length !== header.length) { | ||
@@ -30,3 +30,3 @@ throw new Error(" chunk length = " + messageChunk.length + " message length " + header.length); | ||
this.writeHeaderFunc = options.writeHeaderFunc; | ||
node_opcua_assert_1.assert(typeof this.writeHeaderFunc === "function"); | ||
(0, node_opcua_assert_1.assert)(typeof this.writeHeaderFunc === "function"); | ||
} | ||
@@ -36,3 +36,3 @@ this.sequenceHeaderSize = options.sequenceHeaderSize === undefined ? 8 : options.sequenceHeaderSize; | ||
this.writeSequenceHeaderFunc = options.writeSequenceHeaderFunc; | ||
node_opcua_assert_1.assert(typeof this.writeSequenceHeaderFunc === "function"); | ||
(0, node_opcua_assert_1.assert)(typeof this.writeSequenceHeaderFunc === "function"); | ||
} | ||
@@ -45,3 +45,3 @@ this.signatureLength = options.signatureLength || 0; | ||
if (this.cipherBlockSize === 0) { | ||
node_opcua_assert_1.assert(this.plainBlockSize === 0); | ||
(0, node_opcua_assert_1.assert)(this.plainBlockSize === 0); | ||
// unencrypted block | ||
@@ -52,3 +52,3 @@ this.maxBodySize = this.chunkSize - this.headerSize - this.signatureLength - this.sequenceHeaderSize; | ||
else { | ||
node_opcua_assert_1.assert(this.plainBlockSize !== 0); | ||
(0, node_opcua_assert_1.assert)(this.plainBlockSize !== 0); | ||
// During encryption a block with a size equal to PlainTextBlockSize is processed to produce a block | ||
@@ -58,3 +58,3 @@ // with size equal to CipherTextBlockSize. These values depend on the encryption algorithm and may | ||
this.encryptBufferFunc = options.encryptBufferFunc; | ||
node_opcua_assert_1.assert(typeof this.encryptBufferFunc === "function", "an encryptBufferFunc is required"); | ||
(0, node_opcua_assert_1.assert)(typeof this.encryptBufferFunc === "function", "an encryptBufferFunc is required"); | ||
// this is the formula proposed by OPCUA | ||
@@ -72,3 +72,3 @@ this.maxBodySize = | ||
} | ||
node_opcua_assert_1.assert(this.maxBodySize > 0); // no space left to write data | ||
(0, node_opcua_assert_1.assert)(this.maxBodySize > 0); // no space left to write data | ||
// where the data starts in the block | ||
@@ -82,8 +82,8 @@ this.dataOffset = this.headerSize + this.sequenceHeaderSize; | ||
length = length || buffer.length; | ||
node_opcua_assert_1.assert(buffer instanceof Buffer || buffer === null); | ||
node_opcua_assert_1.assert(length > 0); | ||
(0, node_opcua_assert_1.assert)(buffer instanceof Buffer || buffer === null); | ||
(0, node_opcua_assert_1.assert)(length > 0); | ||
let l = length; | ||
let inputCursor = 0; | ||
while (l > 0) { | ||
node_opcua_assert_1.assert(length - inputCursor !== 0); | ||
(0, node_opcua_assert_1.assert)(length - inputCursor !== 0); | ||
if (this.cursor === 0) { | ||
@@ -95,3 +95,3 @@ this._push_pending_chunk(false); | ||
const nbToWrite = Math.min(length - inputCursor, spaceLeft); | ||
this.chunk = this.chunk || node_opcua_buffer_utils_1.createFastUninitializedBuffer(this.chunkSize); | ||
this.chunk = this.chunk || (0, node_opcua_buffer_utils_1.createFastUninitializedBuffer)(this.chunkSize); | ||
if (buffer) { | ||
@@ -123,12 +123,12 @@ buffer.copy(this.chunk, this.cursor + this.dataOffset, inputCursor, inputCursor + nbToWrite); | ||
if (this.signBufferFunc) { | ||
node_opcua_assert_1.assert(typeof this.signBufferFunc === "function"); | ||
node_opcua_assert_1.assert(this.signatureLength !== 0); | ||
(0, node_opcua_assert_1.assert)(typeof this.signBufferFunc === "function"); | ||
(0, node_opcua_assert_1.assert)(this.signatureLength !== 0); | ||
const signatureStart = this.dataEnd; | ||
const sectionToSign = chunk.slice(0, signatureStart); | ||
const signature = this.signBufferFunc(sectionToSign); | ||
node_opcua_assert_1.assert(signature.length === this.signatureLength); | ||
(0, node_opcua_assert_1.assert)(signature.length === this.signatureLength); | ||
signature.copy(chunk, signatureStart); | ||
} | ||
else { | ||
node_opcua_assert_1.assert(this.signatureLength === 0, "expecting NO SIGN"); | ||
(0, node_opcua_assert_1.assert)(this.signatureLength === 0, "expecting NO SIGN"); | ||
} | ||
@@ -138,11 +138,11 @@ } | ||
if (this.plainBlockSize > 0) { | ||
node_opcua_assert_1.assert(this.dataEnd !== undefined); | ||
(0, node_opcua_assert_1.assert)(this.dataEnd !== undefined); | ||
const startEncryptionPos = this.headerSize; | ||
const endEncryptionPos = this.dataEnd + this.signatureLength; | ||
const areaToEncrypt = chunk.slice(startEncryptionPos, endEncryptionPos); | ||
node_opcua_assert_1.assert(areaToEncrypt.length % this.plainBlockSize === 0); // padding should have been applied | ||
(0, node_opcua_assert_1.assert)(areaToEncrypt.length % this.plainBlockSize === 0); // padding should have been applied | ||
const nbBlock = areaToEncrypt.length / this.plainBlockSize; | ||
const encryptedBuffer = this.encryptBufferFunc(areaToEncrypt); | ||
node_opcua_assert_1.assert(encryptedBuffer.length % this.cipherBlockSize === 0); | ||
node_opcua_assert_1.assert(encryptedBuffer.length === nbBlock * this.cipherBlockSize); | ||
(0, node_opcua_assert_1.assert)(encryptedBuffer.length % this.cipherBlockSize === 0); | ||
(0, node_opcua_assert_1.assert)(encryptedBuffer.length === nbBlock * this.cipherBlockSize); | ||
encryptedBuffer.copy(chunk, this.headerSize, 0); | ||
@@ -177,3 +177,3 @@ } | ||
const extraNbPaddingByte = Math.floor(nbPaddingByteTotal / 256); | ||
node_opcua_assert_1.assert(extraNbPaddingByte === 0 || this.plainBlockSize > 256, "extraNbPaddingByte only requested when key size > 2048"); | ||
(0, node_opcua_assert_1.assert)(extraNbPaddingByte === 0 || this.plainBlockSize > 256, "extraNbPaddingByte only requested when key size > 2048"); | ||
// write the padding byte | ||
@@ -212,3 +212,3 @@ this.chunk.writeUInt8(nbPaddingByte, this.cursor + this.dataOffset); | ||
const adjustedLength = this.sequenceHeaderSize + this.cursor + this.signatureLength; | ||
node_opcua_assert_1.assert(adjustedLength % this.plainBlockSize === 0); | ||
(0, node_opcua_assert_1.assert)(adjustedLength % this.plainBlockSize === 0); | ||
const nbBlock = adjustedLength / this.plainBlockSize; | ||
@@ -215,0 +215,0 @@ extraEncryptionBytes = nbBlock * (this.cipherBlockSize - this.plainBlockSize); |
@@ -9,3 +9,3 @@ "use strict"; | ||
const node_opcua_factory_1 = require("node-opcua-factory"); | ||
const schemaSequenceHeader = node_opcua_factory_1.buildStructuredType({ | ||
const schemaSequenceHeader = (0, node_opcua_factory_1.buildStructuredType)({ | ||
baseType: "BaseUAObject", | ||
@@ -29,16 +29,16 @@ fields: [ | ||
if (node_opcua_factory_1.parameters.debugSchemaHelper) { | ||
node_opcua_factory_1.check_options_correctness_against_schema(this, schema, options); | ||
(0, node_opcua_factory_1.check_options_correctness_against_schema)(this, schema, options); | ||
} | ||
this.sequenceNumber = node_opcua_factory_1.initialize_field(schema.fields[0], options.sequenceNumber); | ||
this.requestId = node_opcua_factory_1.initialize_field(schema.fields[1], options.requestId); | ||
this.sequenceNumber = (0, node_opcua_factory_1.initialize_field)(schema.fields[0], options.sequenceNumber); | ||
this.requestId = (0, node_opcua_factory_1.initialize_field)(schema.fields[1], options.requestId); | ||
} | ||
encode(stream) { | ||
super.encode(stream); | ||
node_opcua_basic_types_1.encodeUInt32(this.sequenceNumber, stream); | ||
node_opcua_basic_types_1.encodeUInt32(this.requestId, stream); | ||
(0, node_opcua_basic_types_1.encodeUInt32)(this.sequenceNumber, stream); | ||
(0, node_opcua_basic_types_1.encodeUInt32)(this.requestId, stream); | ||
} | ||
decode(stream) { | ||
super.decode(stream); | ||
this.sequenceNumber = node_opcua_basic_types_1.decodeUInt32(stream); | ||
this.requestId = node_opcua_basic_types_1.decodeUInt32(stream); | ||
this.sequenceNumber = (0, node_opcua_basic_types_1.decodeUInt32)(stream); | ||
this.requestId = (0, node_opcua_basic_types_1.decodeUInt32)(stream); | ||
} | ||
@@ -45,0 +45,0 @@ } |
{ | ||
"name": "node-opcua-chunkmanager", | ||
"version": "2.49.0", | ||
"version": "2.51.0", | ||
"description": "pure nodejs OPCUA SDK - module -chunkmanager", | ||
@@ -14,13 +14,13 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"chalk": "4.1.1", | ||
"node-opcua-assert": "2.42.0", | ||
"node-opcua-basic-types": "2.47.0", | ||
"node-opcua-binary-stream": "2.42.0", | ||
"node-opcua-buffer-utils": "2.42.0", | ||
"node-opcua-factory": "2.49.0", | ||
"node-opcua-packet-assembler": "2.42.0" | ||
"chalk": "4.1.2", | ||
"node-opcua-assert": "2.51.0", | ||
"node-opcua-basic-types": "2.51.0", | ||
"node-opcua-binary-stream": "2.51.0", | ||
"node-opcua-buffer-utils": "2.51.0", | ||
"node-opcua-factory": "2.51.0", | ||
"node-opcua-packet-assembler": "2.51.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "15.6.1", | ||
"node-opcua-debug": "2.42.0", | ||
"@types/node": "16.7.10", | ||
"node-opcua-debug": "2.51.0", | ||
"should": "^13.2.3", | ||
@@ -44,3 +44,3 @@ "source-map-support": "^0.5.19" | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "81654553c6d317fd918ca99b749550eb5e951c23" | ||
"gitHead": "75feb111daf7ec65fa0111e4fa5beb8987fd4945" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82756
+ Added@types/lodash@4.14.172(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addednode-opcua-assert@2.51.0(transitive)
+ Addednode-opcua-basic-types@2.51.0(transitive)
+ Addednode-opcua-binary-stream@2.51.0(transitive)
+ Addednode-opcua-buffer-utils@2.51.0(transitive)
+ Addednode-opcua-constants@2.51.0(transitive)
+ Addednode-opcua-date-time@2.51.0(transitive)
+ Addednode-opcua-debug@2.51.0(transitive)
+ Addednode-opcua-enum@2.51.0(transitive)
+ Addednode-opcua-factory@2.51.0(transitive)
+ Addednode-opcua-guid@2.51.0(transitive)
+ Addednode-opcua-nodeid@2.51.0(transitive)
+ Addednode-opcua-packet-assembler@2.51.0(transitive)
+ Addednode-opcua-status-code@2.51.0(transitive)
+ Addednode-opcua-utils@2.51.0(transitive)
- Removed@types/lodash@4.14.170(transitive)
- Removedchalk@4.1.1(transitive)
- Removednode-opcua-assert@2.42.0(transitive)
- Removednode-opcua-basic-types@2.47.0(transitive)
- Removednode-opcua-binary-stream@2.42.0(transitive)
- Removednode-opcua-buffer-utils@2.42.0(transitive)
- Removednode-opcua-constants@2.42.0(transitive)
- Removednode-opcua-date-time@2.42.0(transitive)
- Removednode-opcua-debug@2.42.0(transitive)
- Removednode-opcua-enum@2.42.0(transitive)
- Removednode-opcua-factory@2.49.0(transitive)
- Removednode-opcua-guid@2.42.0(transitive)
- Removednode-opcua-nodeid@2.45.0(transitive)
- Removednode-opcua-packet-assembler@2.42.0(transitive)
- Removednode-opcua-status-code@2.42.0(transitive)
- Removednode-opcua-utils@2.44.0(transitive)
Updatedchalk@4.1.2
Updatednode-opcua-assert@2.51.0
Updatednode-opcua-factory@2.51.0