diff --git a/lib/src/nanotdf/models/Policy/AbstractPolicy.ts b/lib/src/nanotdf/models/Policy/AbstractPolicy.ts index ee6c9648..c0d8cf58 100644 --- a/lib/src/nanotdf/models/Policy/AbstractPolicy.ts +++ b/lib/src/nanotdf/models/Policy/AbstractPolicy.ts @@ -46,31 +46,36 @@ abstract class AbstractPolicy implements PolicyInterface { throw new Error('toBuffer() was not implemented'); } -/** - * Parses an ECDSA binding from a given buffer. - * - * @param {Uint8Array} buff - The buffer containing the ECDSA binding. - * @returns {{ bindingLength: number; binding: Uint8Array }} - An object containing the binding length and the binding subarray. - */ + /** + * Parses an ECDSA binding from a given buffer. + * + * @param {Uint8Array} buff - The buffer containing the ECDSA binding. + * @returns {{ bindingLength: number; binding: Uint8Array }} - An object containing the binding length and the binding subarray. + */ static parseECDSABinding(buff: Uint8Array): { bindingLength: number; binding: Uint8Array } { const lengthOfR = buff[0]; const lengthOfS = buff[this.SIZE_OF_LENGTH_FIELD + lengthOfR]; - const bindingLength = this.SIZE_OF_LENGTH_FIELD + lengthOfR + this.SIZE_OF_LENGTH_FIELD + lengthOfS; + const bindingLength = + this.SIZE_OF_LENGTH_FIELD + lengthOfR + this.SIZE_OF_LENGTH_FIELD + lengthOfS; const binding = buff.subarray(0, bindingLength); return { bindingLength, binding }; } -/** - * Parses a binding from a given buffer based on the specified binding type. - * - * @param {Uint8Array} buff - The buffer containing the binding. - * @param {boolean} useEcdsaBinding - Flag indicating whether to use ECDSA binding. - * @param {number} offset - The starting offset in the buffer. - * @returns {{ binding: Uint8Array; newOffset: number }} - An object containing the binding and the new offset. - */ - static parseBinding(buff: Uint8Array, useEcdsaBinding: boolean, offset: number): { binding: Uint8Array; newOffset: number } { + /** + * Parses a binding from a given buffer based on the specified binding type. + * + * @param {Uint8Array} buff - The buffer containing the binding. + * @param {boolean} useEcdsaBinding - Flag indicating whether to use ECDSA binding. + * @param {number} offset - The starting offset in the buffer. + * @returns {{ binding: Uint8Array; newOffset: number }} - An object containing the binding and the new offset. + */ + static parseBinding( + buff: Uint8Array, + useEcdsaBinding: boolean, + offset: number + ): { binding: Uint8Array; newOffset: number } { if (useEcdsaBinding) { const ecdsaBinding = this.parseECDSABinding(buff.subarray(offset)); return { binding: ecdsaBinding.binding, newOffset: offset + ecdsaBinding.bindingLength }; diff --git a/lib/src/nanotdf/models/Policy/PolicyFactory.ts b/lib/src/nanotdf/models/Policy/PolicyFactory.ts index 6c67e3b3..7402524c 100644 --- a/lib/src/nanotdf/models/Policy/PolicyFactory.ts +++ b/lib/src/nanotdf/models/Policy/PolicyFactory.ts @@ -18,7 +18,7 @@ function parse( if (type === PolicyTypeEnum.Remote) { ({ policy, offset } = RemotePolicy.parse( buff.subarray(AbstractPolicy.TYPE_BYTE_LEN), - useEcdsaBinding, + useEcdsaBinding )); } else if ( [